return string in reverse order javascript code example
Example 1: javascript .split().reverse.join
"this is a test string".split("").reverse().join("");
//"gnirts tset a si siht"
//as a function
function reverseString(string){
return string.split("").reverse().join("");}
reverseString("test string");
//"gnirts tset"
Example 2: javascrip reverse text
//more compact way:
"my example text".split("").reverse().join("");
Example 3: js how to reverse a string
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"