Hide/show markers

This commit is contained in:
jim-clark 2019-07-26 14:48:06 -07:00
parent d43d48362b
commit f7ef285292

View file

@ -36,6 +36,15 @@ function init() {
function render() {
// Render the board
board.forEach(function(colArr, colIdx) {
// hide/show the column's marker depending if there are 0's or not
let marker = document.getElementById(`col${colIdx}`);
// <conditional exp> ? <truthy thing to return> : <falsey thing to return>;
marker.style.visibility = colArr.indexOf(0) === -1 ? 'hidden' : 'visible';
// if (colArr.indexOf(0) === -1) {
// marker.style.visibility = 'hidden';
// } else {
// marker.style.visibility = 'visible';
// }
colArr.forEach(function(cell, rowIdx) {
let div = document.getElementById(`c${colIdx}r${rowIdx}`);
div.style.backgroundColor = COLORS[cell];