0
can we make it simple
it's too long
3 odpowiedzi
+ 4
for (let i=1;i<14;i++){
eval(`function audio${i}(){
document.getElementById('sound${i}').play();}`);
}
+ 3
Have the onclick events call one function instead of 16 and pass the number that corresponds to the sound id.
https://code.sololearn.com/WxfZ3TdcQISd/#html
+ 1
//by tanay bhatt
alert(" By Tanay Bhatt");
alert ("this code works well on mobiles");
function start(){
document.getElementById("start").style.display= "none";
}
function audio1(){
document.getElementById('sound1').play();
}
function audio2(){
document.getElementById('sound2').play();
}
function audio3(){
document.getElementById('sound3').play();
}
function audio4(){
document.getElementById('sound4').play();
}
function audio5(){
document.getElementById('sound5').play();
}
function audio6(){
document.getElementById('sound6').play();
}
function audio7(){
document.getElementById('sound7').play();
}
function audio8(){
document.getElementById('sound8').play();
}
function audio9(){
document.getElementById('sound9').play();
}
function audio10(){
document.getElementById('sound10').play();
}
function audio11(){
document.getElementById('sound11').play();
}
function audio12(){
document.getElementById('sound12').play();
}
function audio13(){
document.getElementById('sound13').play();
}
function aud