C
C#3y ago
populus

Sequential 'ForEach' functions doesn't work.

tileMap01.mapGrid.forEach( element => {
element.forEach( ele => {
console.log(ele);
switch(ele) {
case " ":
let iele = document.createElement(img);
iele.id = "emptyImg" + counter++;
console.log(iele.id);
iele.src = "/images/tile1.png";

console.log(iele);

document.body.appendChild(iele);
tileMap01.mapGrid.forEach( element => {
element.forEach( ele => {
console.log(ele);
switch(ele) {
case " ":
let iele = document.createElement(img);
iele.id = "emptyImg" + counter++;
console.log(iele.id);
iele.src = "/images/tile1.png";

console.log(iele);

document.body.appendChild(iele);
6 Replies
populus
populusOP3y ago
tileMap01 is an object and mapGrid is an array of arrays. It is a 'game map' composed of values like " " for blank, "W" for wall, "B" for box, etc.
Thinker
Thinker3y ago
This is JS?
populus
populusOP3y ago
Yes, JS. oh so sorry
Thinker
Thinker3y ago
This is a C# server. $js
populus
populusOP3y ago
yeah i just realized, thanks.
Want results from more Discord servers?
Add your server