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

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

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.

الأجوبة

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"));
هل كان المحتوى مفيد؟

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

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