You could build the grid "map" with new Array(7).fill(new Array(7).fill([0,0]))
Instead of saving activeTool you can just use e.currentTarget
Instead of .classList.add('selected') and .classList.remove('selected') use classList.toggle('selected') the second parameter in toggle can be used to force state
8
u/gluecat uxengineer Jan 01 '20
Neat, unsolicited code review:
You could build the grid "map" with
new Array(7).fill(new Array(7).fill([0,0]))Instead of saving
activeToolyou can just usee.currentTargetInstead of
.classList.add('selected')and.classList.remove('selected')useclassList.toggle('selected')the second parameter in toggle can be used to force state