doubler.operationsByType = { number: (input) => input + input,
Coding Tip: Try to Code Without If-statements
Samer Buna
8.6K13

Using an object as a mapping mechanism is an smart approach that I use often. Tends to simplify the code a lot. Some coworkers got amazed how I converted they huge switch statement into a simple object lookup. If you are teaching this to your students, then god bless you, we really need better devs on JS community.

PS: Technically we are using the object in a way that is very close to the switch statement, but given the exercise requirements it is totally correct :D

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.