Q:

Write a JavaScript program to move last three character to the start of a given string. The string length must be greater or equal to three

0

Write a JavaScript program to move last three character to the start of a given string. The string length must be greater or equal to three.

All Answers

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

function right_three(str) {
     if (str.length > 1)
       {
         return str.slice(-3) + str.slice(0, -3);
       }
  return str;
}
console.log(right_three("Python"));
console.log(right_three("JavaScript"));
console.log(right_three("Hi"));

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