Do you have a shortcut for my code?
Hello, Lost in javascript, the head on the verge of explosion, the eyes on all forums I try to understand the subtlety of this sweet language... However I think my code is similar to my English: it's'nt fluent not clear and probably have a little questionable syntax. Could you give me your opinion, give me avenues to explore to improve my writing (in javascript, for English it's screwed!) Thanks you a lot! - - - - - - - - - H T M L - - - - - - - - - <p> function with<span class="chg">var</span>() {<br/> <span class="chg">var</span> x=1;<br/> if (true) {<br/> <span class="chg">var</span> x=2;<br/> console.log(x);}<br/>} </p> <input type="text" name="reponse" value="output : 22" id="rps"></input> <input type="button" onclick="aveclet()" value="Avec let" id="btn"/> </div> - - - - - - - - - J A V A S C R I P T - - - - - - - - - let clicbtn = 0; function aveclet(){ let chg = document.getElementsByClassName("chg"); clicbtn+=1; if(clicbtn==1){ for (let i=0;i<chg.length;i++){ chg[i].innerHTML="let"; } let rps = document.getElementById("rps"); rps.value="output : 21"; let btn = document.getElementById("btn"); btn.value="avec const";} else if (clicbtn==2){ for (let i=0;i<chg.length;i++){ chg[i].innerHTML="const"; } let rps = document.getElementById("rps"); rps.value="output : 21"; let btn = document.getElementById("btn"); btn.value="avec var";} else if (clicbtn==3){ for (let i=0;i<chg.length;i++){ chg[i].innerHTML="var"; } let rps = document.getElementById("rps"); rps.value="output : 22"; let btn = document.getElementById("btn"); btn.value="avec let";} else {clicbtn=1; for (let i=0;i<chg.length;i++){ chg[i].innerHTML="let"; } let rps = document.getElementById("rps"); rps.value="output : 21"; let btn = document.getElementById("btn"); btn.value="avec const";} } PS: It's about small dictatiel which allow me to assimilate the matter by putting it in situation. Nothing very sexy th