Advertisement
CoineTre

Array Reverse - Kata

Oct 9th, 2024
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.84 KB | Source Code | 0 0
  1. function arrayReverse(words) {
  2.   let wordLength = [];
  3.   let newWord = words.join('').split('').reverse().join('');
  4.     for(let word of words){
  5.     let length = word.length;
  6.     wordLength.push(newWord.substring(0,length));
  7.     newWord = newWord.slice(length);
  8.   }
  9.     return(wordLength);
  10. }
  11. console.log(arrayReverse(['Finest', 'Bakery'])); //=== ['yrekaB', 'tseniF']
  12.  
  13.  
  14.  
  15. /*Array reverse - kata/codewars
  16. Write a function arrayReverse that accepts an array of strings words consists of Latin letters, numbers and special symbols.
  17. Reverse the given strings in the array and their order so that the length of the strings from the original array does not change, e.g. if the length of the first string is 1, and the length of the last is 5, then when reversing, the first string in the array will contain only the last character from the last string.
  18. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement