Merhaba felsefe projem icin bir odev yapiyordum ancak kodum cok uzun oldu. Python'da nasıl yapardim biliyorum ama JS ilk kez kullanıyorum acaba nasıl kisaltabilirim kodu kisaltmanizi istemiyorum sadece neyi nasıl yapicagami soylerseniz sevinirim teşekkurler.

Kod:Panoya kopyala
var q1a, q2a, q3a, q4a, q5a, q6a, q7a, q8a, q9a, q10a, q11a, q12a. var q1q,a1q,q2q,a2q,q3q,a3q,q4q,a4q,q5q,a5q,q6q,a6q,q7 q,a7q,q8q,a8q,q9q,a9q,q10q,a10q,q11q,a11q,q12q,a12 q var wrong = new Audio('wrong.mp3'); function resetall() else if (q2a==true) else if (q3a==true) else if (q4a==true) else if (q5a==true) else if (q6a==true) else if (q7a==true) else if (q8a==true) else if (q9a==true) else if (q10a==true) else if (q1a==true) else if (q12a==true) else } resetall() function q1() } function a1() else,300) document.querySelectorAll('#a1').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q2() } function a2() else,300) document.querySelectorAll('#a2').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q3() } function a3() else,300) document.querySelectorAll('#a3').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q4() } function a4() else,300) document.querySelectorAll('#a4').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q5() } function a5() else,300) document.querySelectorAll('#a5').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q6() } function a6() else,300) document.querySelectorAll('#a6').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q7() } function a7() else,300) document.querySelectorAll('#a7').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q8() } function a8() else,300) document.querySelectorAll('#a8').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q9() } function a9() else,300) document.querySelectorAll('#a9').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q10() } function a10() else,300) document.querySelectorAll('#a10').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q11() } function a11() else,300) document.querySelectorAll('#a11').forEach(e => e.style.color = 'rgb(255,0,0)'); } } function q12() } function a12() else,300) document.querySelectorAll('#a12').forEach(e => e.style.color = 'rgb(255,0,0)'); } }