Liliana797979

reversed array - fundamentals

Jun 2nd, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function reverseArray(num , arrayExample){
  2.     let newArray = [];
  3.     for(let i = 0; i < num; i++){
  4.         let currentIndex = arrayExample[i];
  5.         newArray.push(currentIndex);
  6.     }
  7.  
  8.     newArray.reverse();
  9.     let output = '';
  10.     for(let j = 0; j < newArray.length; j++){
  11.         let currentChar = newArray[j];
  12.         output += ` ${currentChar}`;
  13.     }
  14.     console.log(output);
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment