Sachin Kadam Sachin Kadam - 10 months ago 45
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