DEV Community

Discussion on: Interview Qs Decoded - # 2

Collapse
 
ryands17 profile image
Ryan Dsouza • Edited

Great one! I though have a slightly different take if you don't want to create an intermediate array :)

function revFunction(str){
   const reversedString = [];
   for(let i = str.length - 1; i >= 0; i--){
       reversedString.push(str[i]);
   }
   return reversedString.join('');
};