0
A clear() function was created to clear the numbers inserted in a display by another addNumber() function, but the first function is not having any effect when used.
Tips on how I can solve this problem, or improve my code?.
const operation = document.querySelectorAll("[data-operation]")
const numbers = document.querySelectorAll("[data-content]")
const del = document.querySelector("[data-del]")
const allClear = document.querySelector("[data-ac]")
const displayPrevious = document.querySelector("[data-previous]")
const displayCurrent = document.querySelector("[data-current]")
const displayOperator = document.querySelector("[data-operator]")
function clear (){
displayCurrent.innerHTML = " "
}
function addNumber(number){
number = event.target.innerHTML
if(number === "." && displayCurrent.innerHTML.includes(".")){
return
}
displayCurrent.innerHTML += number
}
You have the HTML for this JS. I ask because depending on the elements evolved sometimes has one or two particularities that can be explored facilitating coding.
– Augusto Vasques