0

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

"December".reverse();

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

1 Answer 1

1

Try this ?

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

"test".reverse() // tset

Don't forget to define the propotype before use it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.