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"
return str.split("").reverse().join("");
function reverse(str){
let reversed = "";
for (var i = str.length - 1; i >= 0; i--){
reversed += str[i];
}
return reversed;
}
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
let a = "foo";
// function for reversing a string
function reverseString(str) {
return str.split("").reverse().join("");
}
console.log(a); // "foo"
let b = reverseString(a);
console.log(b); // "oof"
const reverse = (str) => str.split("").reverse().join("");