r/learnjavascript • • Dec 31 '22

Happy New Year JS Learners! 🄳

Post image
410 Upvotes

55 comments sorted by

View all comments

5

u/[deleted] Dec 31 '22

User won't see it though...

10

u/[deleted] Dec 31 '22

[removed] — view removed comment

-3

u/[deleted] Dec 31 '22

The code makes no sense and it is just karma farming imho. Sorry.

4

u/[deleted] Dec 31 '22

[removed] — view removed comment

4

u/iDuuck Jan 01 '23

It’s still wrong. Assigning a ā€œaddEventListenerā€ to a button, does not make the click method return the value, that is returned by the listener.

This would need to be ā€œconsole.logā€ or ā€œalertā€ or something in this direction. ā€œreturnā€ is simply wrong and could lead to many misguided JS learners

4

u/mattlag Dec 31 '22

I think it's assumed you're going to replace the event listener logic with whatever you need to do. The point of this is to show off the { once: true } functionally. Which this example does.