0

can we make it simple

it's too long

15th Apr 2019, 5:26 AM
Yui Yuuki
Yui Yuuki - avatar
3 odpowiedzi
+ 4
for (let i=1;i<14;i++){ eval(`function audio${i}(){ document.getElementById('sound${i}').play();}`); }
15th Apr 2019, 5:30 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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
15th Apr 2019, 6:50 AM
ODLNT
ODLNT - avatar
+ 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
15th Apr 2019, 5:27 AM
Yui Yuuki
Yui Yuuki - avatar