79112516

Date: 2024-10-22 05:19:07
Score: 0.5
Natty:
Report link

I see a couple of issues with the JavaScript part of the code. Let's walk through them and correct them:

  1. document.querySelectorAll(".numbers") returns a NodeList, but in your for loop, you're using numberOfbuttons directly, which will result in an error because you can't iterate over a NodeList like an integer. Instead, you need to get the length of the NodeList.
  2. The grid-area for the button[value="0"] is incorrect (grid-area: 5/2/5/2;). The grid-area property should be written as four values representing the start-row, start-column, end-row, and end-column, but the values you used are duplicated. If this was intended to position the button, it might need adjusting.
  3. You are statically setting the result to "1" for all buttons. You might want to dynamically set the result to the button's value when clicked.

let numberOfButtons = document.querySelectorAll(".numbers");

for (let i = 0; i < numberOfButtons.length; i++) { numberOfButtons[i].addEventListener("click", function() { document.querySelector(".result").innerHTML = this.innerHTML; // Update result with clicked button's value }); }

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: cyber_steppa