how to reverse a string words in javascript code example
Example 1: javascript reverse string
function reverseString(str) {
return str.split("").reverse().join("");
}
reverseString("hello");
Example 2: reverse a word javascript
function reverseWords(str) {
const allWords = str.split(" ")
return allWords.map(item => item.split("").reverse().join("")).join(" ")
}