Numbers Flashcards

1
Q

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.

A
var a = 42;
var b = -33;
var c = 3.14;
var d = -0.45;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Using exponential notation, create a variable named “GermanyGDP” and assign the number 3.4 trillion (3400000000000) to it.

A

var GermanyGDP = 3.4E12;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create a variable named “mevol” and assign the value 16 to it using an octal number literal.

A

var mevol = 020;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Create a new variable named “numWidth” and use the “parseInt” method to extract the numeric value from boxWidth’s string value.

A

var numWidth = parseInt(boxWidth, 10);

var numVariable = parseInt(stringVariable, radix);
radix = base number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create a new variable named “numHeight” and use the “parseInt” method to extract the numeric value from boxHeight’s string value.

A

var numHeight = parseInt(boxHeight, 10);

var numVariable = parseInt(stringVariable, radix);
radix = base number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Select the correct value for “mood” after this code executes:

var caffeine_mg = 62;
var mood;

if (caffeine_mg = 100) {
mood = ‘winning!’;

A

operational

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What operator is the “less-than or equal-to” operator?

A

<=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What operator would test that two variables have the same value and the same type?

A

===

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F: 10 == “ten”

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Math.PI

Create a variable named “circumference” and assign the correct value to it by using the “diameter” variable and Math.PI.

A

Approximately 3.14159

var circumference = Math.PI * diameter;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Math.random()

Create a variable named “chance” and assign a random number between 0 and 20 to it using the Math.random() method.

A

Returns a random number between 0 and 1

var chance = Math.random() * 20;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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.

A

Returns the largest value of the passed arguments

var maxWidth = Math.max(a, b, c);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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.

A

Returns the value of a number rounded down to the nearest integer

var age = Math.floor(ageIfILiveToYear2100);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly