I’m making a color guesser. It gives an RGB and multiple choices and you have to guess which one is correct. I made a <div>
with grid and put six <div>
s there that will be the choices, but when I wrote the following code, the rgb
did not work but it did not give any errors.
const colorMap = new Map;
var colorSelector = Math.round(Math.random() * 5);
RandomCreator = () => Math.round(Math.random() * 254);
ColorCreator = (x) => {
colorMap.set("red" + x, RandomCreator());
colorMap.set("green" + x, RandomCreator());
colorMap.set("blue" + x, RandomCreator());
}
for (let count = 0; count < 6; count++) {
ColorCreator(count);
document.querySelector('#colors :nth-child(' + (count + 1) + ')').style.backgroundColor = "rgb(" + colorMap.get("+red+" + count) + "," + colorMap.get("+green+" + count) + "," + colorMap.get("blue" + count) + ")";
}
#colors div{
width: 100px;
height: 100px;
}
<div id="colors">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>