Javascript String reverse a string

Description

Javascript String reverse a string

// reverse String
var reverseString = function (s) {
    var newString = "";
    for (var i = s.length - 1; i >= 0; i--) {
        newString = newString.concat(s[i]);
    }//from   w ww .  j  a va  2s. c o  m
    return newString;
};
//test case
console.log(reverseString("abcdefghijk"));



PreviousNext

Related