getElementsByClassName
method to get all of the squares:
let squares = document.getElementsByClassName(`square`)Then use a for...of loop to add an event listener to each square:
for (let square of squares) { square.addEventListener(`click`, toggleSquare) }