DEV Community

Sam E. Lawrence
Sam E. Lawrence

Posted on • Edited on

2 1

Chaining 'let' and 'const' statements

It's now pretty obvious to me that a feature like this would be possible, but it's one of those things that you don't think about until you see it for the first time. I'm working on a Blackjack game as part of a Pluralsight tutorial and I just saw the instructor chain together multiple let and const statements using commas.

const suits = ['Hearts', 'Clubs', 'Diamonds', 'Spades'],
  values = ['Ace', 'King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven', 'Six', 'Five', 'Four', 'Three', 'Two'];

let textArea = document.getElementById('text-area'),
  newGameButton = document.getElementById('new-game-button'),
  hitButton = document.getElementById('hit-button'),
  stayButton = document.getElementById('stay-button');
Enter fullscreen mode Exit fullscreen mode

It's a pretty minor change to my coding practice, but I love the way it visually organizes the code on the page. I think I'll be using this more often when I can, if only for the aesthetic value.

Top comments (0)

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay