JavaScript - Reverse a string



Reverse the provided string. You may need to turn the string into an array before you can reverse it. Your result must be a string.


Solution - Basic approach


console = { 
    log: print,
    warn: print,
    error: print
};
function reverseString(str) {
    
    return str.split("").reverse().join("");
}
console.log(reverseString("hello"));

Output:


olleh

download android app

Popular javascript Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube