All About Closures: Adding Suffixes

Published by bangyen in

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

Examples

let add_ly = add_suffix("ly")

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

let add_less = add_suffix("less")

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

Notes

N/A

Watch a quick demo on how Edabit works.