• Thursday , 14 September 2017

## Javascript Tutorial 2 – Making a Basic Calculator

In this tutorial I show you how to make a very basic calculator, this uses many aspects of javascripts, and provides a good starter package of information for any one that is interested in what javascript can do. On that note, this is the absolue basics of what JS can do. Enjoy there is more to come.

Original source

## Related Posts

1. ##### Kevin Rodriguez
September 10, 2017 at 20:13

Great video, very informative. I had a simple question: How do you set the number of decimal places displayed? Thanks in advance.

2. ##### Wes K.
September 10, 2017 at 20:13

The syntax I was looking for without all of the fluff. Nice.

3. ##### Joseph John
September 10, 2017 at 20:13

can you help me out we need a website that enable you to order and calculat??

4. ##### Ted Telet
September 10, 2017 at 20:13

Once created the app, how to upload it as build-in function to my website ?﻿

5. ##### Matteo Corona
September 10, 2017 at 20:13

For those who are having problems a lighter and working script:

function calc() {

num1 = document.getElementById('num1').value;
num2 = document.getElementById('num2').value;
sign = document.getElementById('sign').value;

if(sign == "*"){

document.getElementById('result').value = +num1 * +num2;

}else if(sign == "/"){

document.getElementById('result').value = +num1 / +num2;

}else if(sign == "-"){

document.getElementById('result').value = +num1 – +num2;

}else{

document.getElementById('result').value = +num1 + +num2;

}

}

6. ##### Daniel Kapper
September 10, 2017 at 20:13

got it to work forgot the doCalc(); at the end

7. ##### Daniel Kapper
September 10, 2017 at 20:13

It is not working for me.

8. ##### Joyce Yan
September 10, 2017 at 20:13

I met the same problem. could u tell me the solution?

9. ##### schwimp
September 10, 2017 at 20:13

This helped me with my finals 😀 thanks a lot!!

10. ##### 2Beings
September 10, 2017 at 20:13

nevermind i foun the solution 😀

11. ##### 2Beings
September 10, 2017 at 20:13

Hey man im getting an error when i calculate it says in the console that calc is not defined please help me man 😀

12. ##### MrMaestro14231
September 10, 2017 at 20:13

u should use html entities for the ×÷ signs

13. ##### Nickdee21
September 10, 2017 at 20:13

Followed your instructions step by step and it works! thanks for posting this!

14. ##### Ezra Sitt
September 10, 2017 at 20:13

wheres part 1