Javascript Calculator. Atlast found the bug

hello guys,
Struggled the whole week and basically wrote the whole code again. Atlast found the bug and now i am passing all the tests.
Here is my project

Your reviews/feedbacks are welcomed.
Never give up and have a great weekend.


Cool, good job.

If I put on my critic hat…

The buttons overlap the bottom part of the display, hiding the bottom of the numbers.

Is the backspace button meant to do anything?

In your html, <p id = "created">by Prayag</p> - that should be in your React, in the JavaScript. Traditionally in React, you don’t put any “real” html in your html, just the hook for React to grab - it does everything else.

Things like if (solved === true) {, that is functionally equivalent to if (solved) {.

It’s a matter of preference, but I probably would have created a Button component to create each of the buttons. Things like “style” could be added conditionally if they exist. And rather than list them individually, I would have stored that data in an array and mapped over them to create them.

But still, that’s getting nitpicky and subjective. Good job.

1 Like

Hello @kevinSmith

Thank you for a detail feedback.
Moved the p tag out of html and also fixed the if statement.
Speaking about the button elements earlier i done the similarly as you mentioned but I kept failing test no. 8 and the following ones and eventually went onto write the current code.
The problem with earlier code was as I was mapping over all the elements that I wanted to represent as buttons and ended you making the textcontent of the button tag string.
But i will try again with two diff arrays one for the ids, values and other for numbers as innerHtml of the button tag.

Good that you were nitpicky it would help me as I am in my earlier stages of learning frontend development.

Thank you once again.

P.S backspace thing is an upcoming feature :sweat_smile:

Cool project! Now I can get rid of windows calculator! :+1:

1 Like

First of all, I didn’t mean that you had to keep working on it - by all means move on. It was just meant informationally. But I’m sure it is possible. The test doesn’t test your code but the end product. It should be possible to do in one array. Maybe I’ll give it a shot.

Haha! Glad that you liked it.

After reading your reply. Now I too feel it can be done in one array.