Getting StartedGiving Commands to ObjectsPrograms 1Programs 2CalculatorVariables: Remembering StuffStrings 1Strings 2InputIfWhile: Loops and Repeating ThingsRandom Numbers and ChooseFSM: The Finite State Machine
Calculator

Picture of a calculator

You can use JavaScript to do math like it's a calculator.

Review of show() command

Remember that you can use the "show" command to show a number on the screen.

Example of adding numbers

You can add up numbers by writing two numbers and putting a plus sign in-between them. Go ahead and try it on the left.

plus, minus, times, divide symbols, with description and example?

You can do other types of math by using different symbols. Because there are no "times" or "divide" buttons on the keyboard, you have to use a * or / instead.

Example of long chain of calculations

You can also put a lot of math on one line and do all the calculations at the same time.

Example of a problem calculation with correct and wrong result

You have to be careful though. JavaScript doesn't do the math from left to right. It uses a special mathematical order.

|

Programming Basics

Programming Basics: Beginners

E-mail | About | Privacy Policy