foundations Flashcards
alert( 5 % 2 );
alert( 8 % 3 );
alert( 8 % 4 );
// 1, the remainder of 5 divided by 2
// 2, the remainder of 8 divided by 3
// 0, the remainder of 8 divided by 4
let x = 0.2 + 0.1;
returns?
0.300000004
let x = 0.2 + 0.1
returns 0.300000004
How to solve this problem to return 0.3?
To solve the problem above, it helps to multiply and divide:
let x = (0.2 * 10 + 0.1 * 10) / 10;
let x = “10”;
let y = “20”;
let z = x + y;
returns?
1020
let x = 10;
let y = “20”;
let z = x + y;
returns?
1020
concatination
let x = “10”;
let y = 20;
let z = x + y;
returns?
1020
concatenation
let x = 10;
let y = 20;
let z = “The result is: “ + x + y;
returns?
1020
let x = 10;
let y = 20;
let z = “30”;
let result = x + y + z;
returns
3030
JavaScript will try to convert _____ to numbers in all numeric operations:
strings
JavaScript will try to convert strings to _______ in all numeric operations:
numbers
JavaScript will try to convert strings to numbers in all numeric operations:
True or false
true
let x = “100”;
let y = “10”;
let z = x + y;
let z = x - y;
let z = x / y;
let z = x * y;
10010
90
10
1000
let x = 100 / “Apple”;
returns?
NAN
You can use the global JavaScript function_______ to find out if a value is a not a number:
isNaN()
let x = NaN;
let y = 5;
let z = x + y;
z returns?
NAN
let x = NaN;
let y = “5”;
let z = x + y;
z returns?
NaN5
NaN is a _____:
Number
typeof NaN returns _______:
Number
Division by 0 (zero) also generates ___________:
Infinity
let x = 2 / 0;
let y = -2 / 0;
infinity
-infinity
Infinity is a _____:
number