You are using =
, the assignment operator, instead of ==
or ===
. That said, you can stop checking explicitly against true
and just check the variable's truthiness for more concise code:
if (is1Pressed) {
console.log("1");
p.innerHTML = "<audio autoplay='autoplay' src='button1.wav'/>";
}
else if (is2Pressed) {
console.log = ("2");
p.innerHTML = "<audio autoplay='autoplay' src='button1.wav'/>";
}
else if (is3Pressed) {
p.innerHTML = "<audio autoplay='autoplay' src='button1.wav'/>";
}
else if (is4Pressed) {
p.innerHTML = "<audio autoplay='autoplay' src='button1.wav'/>";
}
else if (is5Pressed) {
p.innerHTML = "<audio autoplay='autoplay' src='button1.wav'/>";
}
else {
p.innerHTML = "<audio autoplay='autoplay' src='button1.wav'/>";
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…