O'Reilly logo

JavaScript For Kids For Dummies by Eva Holland, Chris Minnick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9

Putting It Together with Operators

An operator is a symbol that performs a task (an operation) using operands. In this chapter, you learn about the different types of operators you can work with in JavaScript.

JavaScript has an operator for every need and a couple operators that you’ll probably never need. Instead of simply listing all the operators, let’s write a program that lets you choose operators and enter in operands and then see the results.

The program will be a Super-Calculator — it can work with words and letters as well as numbers.

image

Introducing the Super-Calculator

You’ve never seen a calculator like this before. Friends, this calculator can do your everyday arithmetic — it can add, subtract, multiply, and even divide. But wait, there’s more! It can also take any two numbers — that’s right, ANY TWO NUMBERS — and tell you how much is left over when you divide one by the other. We call that amazing feature a modulo operation. Get your modulo operation done right here! Free!

But that’s not all! This here Super-Calculator can take words and stick them together! Let’s say you have the word Java and you have the word Script and you wanted to somehow glue them together. Impossible, you say? Hard to believe? Not with the Super-Calculator!

The Super-Calculator gives you the power to glue words together — heck, you can even glue entire sentences — using the concatenation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required