Numbers Flashcards
Create a variable “a” and assign the whole number 42 to it.
Create a variable “b” and assign the negative whole number -33 to it.
Create a variable “c” and assign the decimal number 3.14 to it.
Create a variable “d” and assign the negative decimal number -0.45 to it.
var a = 42; var b = -33; var c = 3.14; var d = -0.45;
Using exponential notation, create a variable named “GermanyGDP” and assign the number 3.4 trillion (3400000000000) to it.
var GermanyGDP = 3.4E12;
Create a variable named “mevol” and assign the value 16 to it using an octal number literal.
var mevol = 020;
Create a new variable named “numWidth” and use the “parseInt” method to extract the numeric value from boxWidth’s string value.
var numWidth = parseInt(boxWidth, 10);
var numVariable = parseInt(stringVariable, radix); radix = base number
Create a new variable named “numHeight” and use the “parseInt” method to extract the numeric value from boxHeight’s string value.
var numHeight = parseInt(boxHeight, 10);
var numVariable = parseInt(stringVariable, radix); radix = base number
Select the correct value for “mood” after this code executes:
var caffeine_mg = 62; var mood;
if (caffeine_mg = 100) {
mood = ‘winning!’;
operational
What operator is the “less-than or equal-to” operator?
<=
What operator would test that two variables have the same value and the same type?
===
T/F: 10 == “ten”
False
Math.PI
Create a variable named “circumference” and assign the correct value to it by using the “diameter” variable and Math.PI.
Approximately 3.14159
var circumference = Math.PI * diameter;
Math.random()
Create a variable named “chance” and assign a random number between 0 and 20 to it using the Math.random() method.
Returns a random number between 0 and 1
var chance = Math.random() * 20;
Math.max(a, b, …)
Create a variable named “maxWidth” and assign the largest value of variables a, b, and c to it using the Math.max method.
Returns the largest value of the passed arguments
var maxWidth = Math.max(a, b, c);
Math.floor(a)
There is a variable “ageIfILiveToYear2100” already defined but it has a lot of decimal places. Create a variable named “age” and use the Math.floor method to lop off the decimal digits.
Returns the value of a number rounded down to the nearest integer
var age = Math.floor(ageIfILiveToYear2100);