Challenges
Most challenges faced were with the handling of calculations for the calculator. Making separate functions and using a loop to assign specific function to most of the keys created a fast coding stance.
- Clicking number function
const numberClick = (element) => { if (needReset) { reset(); } if (screen.innerHTML == 0) { screen.innerHTML = ""; } if ((!isNaN(parseInt(element)) || element == ".") && computation == null) { screen.innerHTML = screen.innerHTML + element; inputOne = screen.innerHTML; } else { screen.innerHTML = screen.innerHTML + element; inputTwo = screen.innerHTML; } };
- For Loop to assign keys function
for (const key of keys) { if (!isNaN(parseInt(key.innerHTML)) || key.innerHTML == ".") { key.addEventListener("click", () => numberClick(key.innerHTML)); } }