AndroidApacheAutomation FrameworkAutomation/QTP/Selenium BlogsGoogle adsenseJava, JavaScriptquestionsTechnical blogTrending

String reverse in java script using decrementing For-loop

Assume given string ‘str’ value is “welcome”
function stringRev(str) {
var stringOne = “”;
for (var i = str.length – 1; i >= 0; i–) {
stringOne = stringOne + str[i];
}
return stringOne; // “emoclew”
}
stringRev(‘welcome’);