Design comparison
SolutionDesign
Solution retrospective
I will really appreciate if someone can help me with how to return a single number when entered in my calculator when no operation is carried out on it after pressing the equal sign button without returning nan
Community feedback
- @BeinRain06Posted about 1 year ago
Great Dolly you added regex function in your javascript code, good work, keep going on.
To fix this bug NaN :
Try to add this line code in :
else if (buttons[I] === equalBtn) { firstNumber = initialNumber[0]; //**add** if (isNaN(firstNumber)) { return counter;// initially counter=0 } counter += firstNumber ; ...
}
You can go ahead and Try it to see if it's working to put the result to zero.
Have a happy coding Dolly
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord