Q:

Write a JavaScript program to create a new string with the results of calling a provided function on every character in the calling string

-2

Write a JavaScript program to create a new string with the results of calling a provided function on every character in the calling string.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const mapString = (str, fn) =>
  str
    .split('')
    .map((c, i) => fn(c, i, str))
    .join('');

console.log(mapString('Javascript exercises', c => c.toUpperCase()));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now