Answers for "how to reverse the string in js"

60

javascript reverse a string

function reverseString(s){
    return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
Posted by: Guest on August-05-2019
2

reverse string js

function reverseString(str) {

    var newString = "";

    for (var i = str.length - 1; i >= 0; i--) { 
        newString += str[i]; 

    return newString;
}
 
reverseString('hello');
Posted by: Guest on January-12-2021
2

javascript reverse string

function reverseString(str) {
  if (str === "")
    return "";
  else
    return reverseString(str.substr(1)) + str.charAt(0);
}
reverseString("hello");
Posted by: Guest on September-03-2020
1

reverse string js

str.split('').reduce((reversed, character) =>{
    return character + reversed;
  }, '');
//apple = leppa
Posted by: Guest on July-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language