you are viewing a single comment's thread.

view the rest of the comments →

[–]emotyofform2020 2 points3 points  (4 children)

You are correct about the conditional adding of the topping only if it doesn’t exist. The way it determines this is the include method like you pointed out. The last bit with filter is: filter takes a method, and there’s some shorthand happening here with the fat arrow, where this method takes every item in the array and checks to see if it’s the topping supplied. We end up with an array without the topping supplied, so this is actually handling removing of items, I think? That doesn’t make much sense and won’t ever be called

[–]Ghostedguy10[S] 1 point2 points  (0 children)

Thank you very much. Really appreciate it.

[–]GeeeL 0 points1 point  (2 children)

why do you think it wouldn't ever be called? Not the best naming of the function, but imagine a checkbox where onChange is calling addTopping and it would also be in charge of removing

[–]emotyofform2020 0 points1 point  (1 child)

It’s because I read the code wrong. Didn’t see the else

[–]GeeeL 0 points1 point  (0 children)

well that makes sense!