Write a JavaScript program to replace the first digit in a string (should contains at least digit) with $ character

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

Write a JavaScript program to replace the first digit in a string (should contains at least digit) with $ character.

الأجوبة

function replace_first_digit(input_str) {

  return input_str.replace(/[0-9]/, '$');
}
console.log(replace_first_digit("abc1dabc"));
console.log(replace_first_digit("p3ython"));
console.log(replace_first_digit("ab1cabc"));   
هل كان المحتوى مفيد؟

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

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