Skip to main content
variable mapString
import { mapString } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Creates a new string with the results of calling a provided function on every character in the calling string.

Use String.prototype.split('') and Array.prototype.map() to call the provided function, fn, for each character in str. Use Array.prototype.join('') to recombine the array of characters into a string. The callback function, fn, takes three arguments (the current character, the index of the current character and the string mapString was called upon).

type

(str: string, fn: MapFunc<string>) => unknown