DEV Community

Sam E. Lawrence
Sam E. Lawrence

Posted on • Edited on

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)