potain/potain03/jeux/assets/camel.js

30 lines
711 B
JavaScript
Raw Normal View History

2021-06-04 23:11:15 +02:00
let counter = new Set();
const MAX_DIFFS = 7;
2021-06-05 16:47:24 +02:00
const foundDisplay = [];
(function () {
const found = document.getElementById("found");
for (let i = 0; i < MAX_DIFFS; i++) {
const li = document.createElement("li");
foundDisplay.push(li);
found.appendChild(li);
}
})();
2021-06-04 23:11:15 +02:00
function zone(name) {
if (!counter.has(name)) {
const content = document.createTextNode(name);
2021-06-05 16:47:24 +02:00
const li = foundDisplay[counter.size];
2021-06-04 23:11:15 +02:00
li.appendChild(content);
2021-06-05 16:47:24 +02:00
counter.add(name);
2021-06-04 23:11:15 +02:00
}
displayCounter();
}
function displayCounter() {
if (counter.size >= MAX_DIFFS) {
win();
}
document.getElementById("counter").innerText = String(counter.size);
}