Q:

Write a JavaScript program to create a new string from a given string with the first character of the given string added at the front and back

0

Write a JavaScript program to create a new string from a given string with the first character of the given string added at the front and back.

All Answers

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

function front_back(str)
{
  first = str.substring(0,1);
  return first + str + first;
}
console.log(front_back('a'));
console.log(front_back('ab'));
console.log(front_back('abc'));

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