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

  • برمجة جافاسكربت java script
  • برمجة

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

الأجوبة

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

console.log(mapString('Javascript exercises', c => c.toUpperCase()));
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...