Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Reverse string in JavaScript

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'));
Source by exploretech.dev #
 
PREVIOUS NEXT
Tagged: #Reverse #string #JavaScript
ADD COMMENT
Topic
Name
7+9 =