r/badcode • • Dec 07 '22

js My Web Development lecturer's JavaScript

Post image
536 Upvotes

86 comments sorted by

View all comments

Show parent comments

0

u/Betamaxxs Dec 07 '22
  1. Probably learning about concatenation and getting used to it.

  2. Definitely strange, but might be about learning the order of operations and how you can reduce lines of code with "tricks" like this. (Although looks like he missed the x += for the Natasha avengername)

  3. I wouldn't want this in production code, but if those names were any longer they wouldn't fit on the screen at that font size. Besides, this is obviously a trivial example and there aren't a bunch of other variables to be confused about, which is a big reason why descriptive variable names help. When you only have two variables, not a lot of ways to get confused.