r/badcode • u/Flyspeck101 Now where's that function declaration • Nov 06 '21
js Something seems off...
247
Upvotes
r/badcode • u/Flyspeck101 Now where's that function declaration • Nov 06 '21
46
u/SnakeFang12 Nov 06 '21
Other than the useless items variable, this looks like reasonable vanilla JS code. Perhaps it's not the most performant snippet in the world but I doubt that'll be noticeable on any modern browser.
38
u/semsemsem2 Nov 06 '21
At least they’re using innerText instead of innerHTML
11
u/Pangocciolo Nov 06 '21
I am too busy ATM to spot the error. What's the matter apart the need for better naming?
7
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 06 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/Blackbird-ce Nov 06 '21
How is 'items' (fetched from the DOM) in line 4 suddenly a property of 'rooms[currentRoom]' in line 5?
1
u/[deleted] Nov 06 '21
I love posts like this. Bad, but not just picking fun at someone writing their first line of code. Opportunity for people to learn something if they're a little green on the front end
1
u/nekokattt Nov 06 '21
I'm surprised no one has made a comment about using jquery yet, despite it being irrelevant.
0
u/[deleted] Nov 06 '21
[deleted] — view deleted comment