Button Clicker | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Button Clicker

How do I make it so my if statement doesn’t straight away go to ten? https://code.sololearn.com/WMCc8aOVtd0i/?ref=app

1st Feb 2022, 11:39 PM
Junior
Junior - avatar
2 Answers
0
Primary issue was the use of = (assignment operator) for testing <counter>, where == (equality operator) should've been used. var counter = 0; function button() { if( counter == 10 ) { return false; // no more click allowed } counter++; document.getElementById("counter").innerHTML = counter; if (counter == 10) { alert("You Win"); } }
1st Feb 2022, 11:49 PM
Ipang
0
<button onclick="/*Your JavaScript Codes*/">text</button>
11th Jun 2022, 12:41 AM
aliz6398suisiTerminatorEmpireBot
aliz6398suisiTerminatorEmpireBot - avatar