Numbers Flashcards
What is one of the most common datatypes in JavaScript?
Strings
What are booleans?
True or false outcomes are booleans.
Can JavaScript numbers do simple and complex math?
Yes
It is possible to do simple + complex math with JS numbers.
How is math used in practical ways online?
Total Cost in online stores
Adding points in online games
Keeping track of metrics in web apps
What role do random numbers play?
Random numbers add variety and surprise to games.
Can numbers be positive or negative in JavaScript numbers?
Yes
Can you use decimals or only whole integers?
Both whole integers and decimals
How do you assign numbers?
You can store numbers in variables by using the equal sign.
Do numbers need special characters?
No, you don’t need quote marks.
If you add quote marks, it’s a string, not a number.
Can you use commas for longer numbers?
Ex: 1,456,789
No
You cannot use commas
Commas produces errors
What is the arithmetic operator for addition?
+
What is the arithmetic operator for subtraction?
-
What is the arithmetic operator for multiplication?
*
What is the arithmetic operator for division?
/
Can you combine variables with numbers as part of JavaScript arithmetic?
Yes
You can add variables with numbers.
Example: game scores
How do you write this in shorthand version?
score = score + 10;
Shorthand version of arithmetic simplifies
it by not having to write the variable name twice.
score += 10;
How do you flip the order of the signs in the shorthand version?
Put the operator before equal sign
+=
-=
*=
/=
For subtraction shorthand, how would you simplify the following code?
score -= 20;
For multiplication, how do you simplify it in shorthand?
For division, what’s the shorthand version?
To create a math program, you should start by
creating your variables and assigning values
Once you have your variables, how do you make your formula?
The formula itself goes into a new variable.
In this example, variables are multiplied by variables.
The solution is assigned to a new variable.