How to Reverse a String

 strName = 'Michael';

 alert(reverse(strName));

 function reverse(s)
  {
    return s.split("").reverse().join("");
  }

Output

 leahciM

Split function Splits the String By Taking “” as Delimiter and Puts in a array.
The Reverse function reverses the array
The join function Joins the array(Character in each cell) again

How to Check if it is Numeric

function isNumber(n) 
{
  return !isNaN(parseFloat(n)) && isFinite(n);
}

One thought on “String Functions

Leave a reply