can somebody tell me why im getting this error

4 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
samidev
samidevOP•2y 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•2y 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
samidevOP•2y ago
well ye thanks mate 😄
Want results from more Discord servers?
Add your server