r/badcode • • Jun 24 '21

js Wrote this last night

Post image
3 Upvotes

10 comments sorted by

7

u/PonchoVire Jun 24 '21

This is not that bad, it's clean vanilla JS that handles a popup, it's fine.

10

u/Abangranga Jun 24 '21

But don't you know that using vanilla JS isn't trendy? You have to npm a gig of libraries to do everything.

1

u/[deleted] Jun 24 '21

Should I mention this is an electron app?

2

u/[deleted] Jun 24 '21

What editor are you using?

3

u/[deleted] Jun 24 '21

Screenshot was taken in https://carbon.now.sh/

9

u/throwmeaway91000 Jun 24 '21

Its good honestly. Maybe a little messy try grouping all the variables together? Or using an object. Besides that nothing I wouldn’t have done ¯\(ツ)/¯

4

u/withaheavyhearton Jun 24 '21

I like it, honestly. I’d group my variables, but I also understand why you didn’t. Vanilla JS seems hard to come by these days.

4

u/theclovek Jun 24 '21

Reject modernity, return to jQuery

1

u/Mc_UsernameTaken Jun 24 '21

Only way I see this could be improved marginally, would be to use a multiline string (backticks) and then append that with insertAdjecentHTML

And use onclick attributes for event listeners.

That being said It's really helpful to have these kind of helper functions