I am making a chess game as a fun project. The way I have it set up involves one variable per square, which is taking me 64 lines of code as of right now.
The variable name should be the same as the ID.
My current code:
const a1 = document.getElementById('a1');
const a2 = document.getElementById('a2');
const a3 = document.getElementById('a3');
const a4 = document.getElementById('a4');
const a5 = document.getElementById('a5');
const a6 = document.getElementById('a6');
const a7 = document.getElementById('a7');
const a8 = document.getElementById('a8');
(goes on for 7 more sets of 8)
I have not tried anything else yet because I'm not sure where to start.
Are there any methods to shorten this? Thanks in advance!