Assume given string ‘str’ value is “welcome”
function stringRev(str) {
var splitString = str.split(“”);// Use the reverse() method to reverse the array
var arrayReverse = splitString.reverse(); // equals to [“e”, “m”, “o”, “c”, “l”, “e”, “w”]
var splitString = str.split(“”);// Use the reverse() method to reverse the array
var arrayReverse = splitString.reverse(); // equals to [“e”, “m”, “o”, “c”, “l”, “e”, “w”]
// Use join() method to join the elements of the array into a string as below in comments
var joinArray = arrayReverse .join(“”); // [“e”, “m”, “o”, “c”, “l”, “e”, “w”] to “emoclew”
//Return the reversed string
return joinArray; // “emoclew”
}
stringRev(‘welcome’);
Thanks for the update, Informative post.
Here is my link to my blog which also have some free selenium tutorials –