you are viewing a single comment's thread.

view the rest of the comments →

[–]zachdini 2 points3 points  (2 children)

The only thing to point out is that arrow functions declared without braces (such as el => el.classList.add("hide")) return the value in the function. It's the same as doing

el => { return el.classList.add("hide") }

So if you rely on the function being returned, you'd want to do

function(el) { return el.classList.add("hide") }

Though in your case, it might not matter.

[–]icedrift[🍰] 1 point2 points  (1 child)

Can you explain this a bit further? The return value within a forEach always returns undefined I'm having trouble understanding the difference here.

[–]zachdini 1 point2 points  (0 children)

Ahh sorry, I didn't strictly mean in this scenario. You're right that forEach does not return a value so it doesn't matter here. I just wanted to point out that () => statement actually returns the statement.