← Back to challenges

toString() Hooking

JavaScriptHardarraysfunctional_programminglanguage_fundamentals

Instructions

You have one job and one job only, to ruin the day of any unsuspecting victim using the toString() function. Hook the String prototype toString() to instead return a string that is in reverse.

Examples

("Hello World!").toString() ➞ "!dlroW olleH"

("My hooking function! :3").toString() ➞ "3: !noitcnuf gnikooh yM"

("RaceCar").toString() ➞ "raCecaR"

Notes

Remember that this is an object!

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.