← Back to challenges

All About Anonymous Functions: Adding Suffixes

JavaScriptHardlanguage_fundamentalsclosureshigher_order_functions

Instructions

Write a function that returns an anonymous function, which transforms its input by adding a particular suffix at the end.

Examples

add_ly = add_suffix("ly")

add_ly("hopeless") ➞ "hopelessly"
add_ly("total") ➞ "totally"

add_less = add_suffix("less")

add_less("fear") ➞ "fearless"
add_less("ruth") ➞ "ruthless"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Triangular Number Sequence