Javascript String reverse(name)

Description

Javascript String reverse(name)


//Just like you can add methods to your own constructor, you can also add methods and properties to built in classes in JavaScript like Arrays and Objects.

//Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself.

  
String.prototype.reverse = function(name){
 name = name.split("").reverse().join("");
  return name;
}

String.prototype.reverse("Hello world");



PreviousNext

Related