0% found this document useful (0 votes)
20 views

How To Build Calculator W Javascript

Uploaded by

Freedy
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

How To Build Calculator W Javascript

Uploaded by

Freedy
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

STEP BY STEP HOW TO MAKE A CALCULATER

Hello Guys!
Today I am going to talk about making basic calculator with JavaScript.I will start to
explain with HTML and then CSS and last JavaScript.
For HTML we need button to get number from the user.When the user click the
button with JavaScript we can get number from it.
As you can see the below the code page each button has value and class.We are
going to use both with JavaScript and CSS.
It’s up to you to create those button, you can use <table> or add separately. It’s
totally up to your creativity.
And with this CSS code I just try to show them as a real calculator.
Now the most important side of this small project is backend…
Lets try to understand how it’s working :)
Firstly I get it all numbers from button with using .num and then I have an access to
all value by using loop.For each element I create an event to get number which is
clicked.
As you can see I have 2 value as right and left, left value is holding numbers till the
user click any operators and after it left is holding the numbers till the user click the
equal.
And after we have same code for the operators.Same loop, has access to all
operators and then when its clicked selectedOperator hold the value.
Equal has the only button to get know result so we don’t need to use loop for it.Wen
only create event for it.If the operator is one of operators it calculates the    numbers.
And for deleting we only need to make variables empty.
THE LONG AND SHORT OF IT
We have a 4 function;
First one is holding and showing the numbers on the screen.
Second is showing operators.
Third one is calculating the numbers.
And last one is deleting from the screen.

You might also like