JavaScript membalikkan string
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
Grepper
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
function reverse(str){
let reversed = "";
for (var i = str.length - 1; i >= 0; i--){
reversed += str[i];
}
return reversed;
}
const reverseStr = (str)=>{
if(!str || 2 > str.length) {
return str
}
let reversedStr = '';
for (let index = str.length - 1; index >= 0; index--) {
reversedStr += str[index];
}
return reversedStr
}
console.log(reverseStr('football'));