String Reversal(m

Anil Verma's photo
Anil Verma
·Mar 17, 2021·

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Sol#1

function reverse(str) {
return str.split(‘’).reverse().join(‘’);
}

Sol#2

rev =’’
for(let char of str){
rev = char + rev
}

Sol#3

str.split(‘’).reduce((a, b)=> b+ a,’’)

 
Share this