Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
vikas pal11,255 Points
Please Help me to get this website work!
I have created a project on my own in which I want to let the user, to use the calculator on the website provided. I was able to make the keypad structure of the calculator, but now stuck in a problem.
That is how I will calculate the number? Please see the code from the below treehouse workspace fork and help me to calculate the result. I want you to capture the digits of the user by clicking on the digits provided in the keypad instead of typing.
You can also help me by making the CSS better.
The calculator will open when you click on the calculator field.
Here's the Treehouse Fork of this project:-- https://w.trhou.se/2w8ftzlphm
Steven Parker227,141 Points
Hi, I got alerted by your tag.
You seem to have a good start, but there's a bit more coding to be done.
To capture the digits, as you create the buttons, you could call "addEventListener" on each one to give it a function to handle the "click" event. Or, you could have a single delegated handler on the "space". Then, in that handler function you can store the digits and perform the calculations using the button label to choose the action. You still need to add an element to act as the "display" of the calculator where you can show the result.
And one suggestion for the CSS would be to add "
cursor: pointer;" to the buttons to visually indicate that they are clickable.