Skip to content
Advertisement

How to simplify object

I have an issue here where the code is quite heavy and quite hard to read imo.

I’ve simplified the code as much as I can but I was wandering if there’s a way to simplify this code even further? Or maybe if there is any better terminology i could use for the comments? Any help is much appreciated, Thanks in advance!

JavaScript

Advertisement

Answer

You can use Template Strings to simplify booking_name

JavaScript

Also consistency in variable names would better, you could choose one of the variable naming styles, snake_case or camelCase.

Also now you can shorten expression key:value even more.

JavaScript

Also that ternary expression is very hard to read, I think switch case would better.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement