0

Wats wrong with this Javascript code

const decreaser = document.getElementById('decreaser'); const reset = document.getElementById('reset'); const increase = document.getElementById('increase'); let counter = 0; increase.addEventListener("click", function (){ counter += 1; number.innerHTML = counter; }); reset.addEventListener("click", function(){ counter +=0; number.innerHTML = counter; }); decreaser.addEventListener ("click", function(){ counter -= 1; number.innerHTML = counter; });

24th Sep 2022, 6:51 PM
Divine Osiadi
Divine Osiadi - avatar
4 Answers
+ 3
Please link your complete code: Click +, Insert Code, sort for My Code Bits, select your code
24th Sep 2022, 6:56 PM
Lisa
Lisa - avatar
+ 3
You are not created any IDs but searching for those. and 'number' is unknown in number.innerHTML Share link by saving it. Add ids to buttons. & create number division.
24th Sep 2022, 8:45 PM
Jayakrishna 🇼🇳
+ 3
Delete all lines with constants. Instead of: number.innerHTML = counter; Write: document.display.innerHTML = counter;
24th Sep 2022, 9:03 PM
Solo
Solo - avatar
0
<!DOCTYPE html> <html> <head> <title>counter</title> </head> <body> <div class="container"> <h1>Counter</h1> <display>5</display> <button onclick="decreaser()"> Decrease </button> <button onclick="reset()"> Reset </button> <button onclick="increase()"> Increase </button> </div> </body> </html>
24th Sep 2022, 7:34 PM
Divine Osiadi
Divine Osiadi - avatar