Of course, I'm only pointing out the negatives and none of the many positives...
You made a big no-no with some of your functions by NOT naming them as VERBS. "newBurger" is NOT a good function name. What? Are you "newing" it??? How about, "createBurger"? NOW that IS a VERB -- much better!
Also, it is a good thing to implement METHOD CHAINING in your CLASSES, but I see chains used TOO MUCH. My rule, if it's a void return then it should instead return this. However, your example above for total chains .map & .reduce. Instead, you should have 2 variables: prices (mapped) & total (reduced). That way, when more functionality around pricing is added, another [Jr] dev doesn't come along and write var prices = items.map( ({ price }) => price ) -- adding another full iteration to the operation. It's also more informative when we're "reducing prices" rather than "reducing [structure]".
Moreover, JavaScript is both Functional AND OOP, and if you're not using both you're just not going to write good code. Why encourage only Functional? Jr devs automatically, naturally gravitate toward writing Functional code, why not encourage more OOP? That would probably benefit a dev much more.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Of course, I'm only pointing out the negatives and none of the many positives...
You made a big no-no with some of your functions by NOT naming them as VERBS. "newBurger" is NOT a good function name. What? Are you "newing" it??? How about, "createBurger"? NOW that IS a VERB -- much better!
Also, it is a good thing to implement METHOD CHAINING in your CLASSES, but I see chains used TOO MUCH. My rule, if it's a void return then it should instead return
this
. However, your example above fortotal
chains.map
&.reduce
. Instead, you should have 2 variables:prices
(mapped) &total
(reduced). That way, when more functionality around pricing is added, another [Jr] dev doesn't come along and writevar prices = items.map( ({ price }) => price )
-- adding another full iteration to the operation. It's also more informative when we're "reducing prices" rather than "reducing [structure]".Moreover, JavaScript is both Functional AND OOP, and if you're not using both you're just not going to write good code. Why encourage only Functional? Jr devs automatically, naturally gravitate toward writing Functional code, why not encourage more OOP? That would probably benefit a dev much more.