can somebody tell me why im getting this error

4 Replies
Unknown User
Unknown Userβ€’17mo ago
Message Not Public
Sign In & Join Server To View
samidev
samidevβ€’17mo ago
yep here the code
window.addEventListener("load", () => {
const sounds = document.querySelectorAll(".sound");
const pads = document.querySelectorAll(".pads div");
const visual = document.querySelector(".visual");
const colors = [
"##60d394",
"#0a3798",
"#e54f0f",
"#d36098",
"#ab18ef",
"#bad360"

];

pads.forEach(pad, index) => {
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubble(index);
});
};
});

const createBubble = index => {
// create bubbles
const bubble = document.createElement("div");
visual.appendChild(bubble);
bubble.style.backgroundColor = colors[index];
bubble.style.animation = `jump 1s ease`;
bubble.addEventListener("animationend", function() {
visual.removeChild(this);
});
};
window.addEventListener("load", () => {
const sounds = document.querySelectorAll(".sound");
const pads = document.querySelectorAll(".pads div");
const visual = document.querySelector(".visual");
const colors = [
"##60d394",
"#0a3798",
"#e54f0f",
"#d36098",
"#ab18ef",
"#bad360"

];

pads.forEach(pad, index) => {
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubble(index);
});
};
});

const createBubble = index => {
// create bubbles
const bubble = document.createElement("div");
visual.appendChild(bubble);
bubble.style.backgroundColor = colors[index];
bubble.style.animation = `jump 1s ease`;
bubble.addEventListener("animationend", function() {
visual.removeChild(this);
});
};
whole code of js
MarkBoots
MarkBootsβ€’17mo ago
Like @ApplePieCrust already said, you're missing a set of parentheses in the forEach
pads.forEach((pad, index) => {
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubble(index);
});
});
pads.forEach((pad, index) => {
pad.addEventListener("click", function() {
sounds[index].currentTime = 0;
sounds[index].play();
createBubble(index);
});
});
samidev
samidevβ€’17mo ago
well ye thanks mate πŸ˜„