Sachin Kadam Sachin Kadam - 4 months ago 6
Javascript Question

Inline input to custom function

I like to implement reverse() method on string.
But input should be inline. such as,


function reverse(){
return reverse("").join(" ");


Try this ?

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

"test".reverse() // tset

Don't forget to define the propotype before use it