audipower

Cut-And-Reverse

Jul 14th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cutAndReverse(str) {
  2.     let arr = [];
  3.  
  4.     let firstPart = str.substr(0, str.length / 2);
  5.     arr.push(firstPart);
  6.     let secondPart = str.substr(str.length / 2, str.length);
  7.     arr.push(secondPart)
  8.  
  9.     for (let element of arr) {
  10.         console.log(element.split("").reverse().join(""))
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment