reverse sentence javascript code example
Example 1: javascript reverse a string
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");
Example 2: javascrip reverse text
"my example text".split("").reverse().join("");
Example 3: javascript reverse string
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
Example 4: reverse string javascript
const reverse = (str) => str.split("").reverse().join("");
function reverse1(str) {
const arr = str.split("");
arr.reverse();
const res = arr.join("");
return res;
}
function reverse2(str) {
let res = "";
for (let i = 0; i < str.length; i++) res = str[i] + res;
return res;
}
function reverse3(str) {
return str.split("").reduce((output, char) => {
return char + output;
}, "");
}