Numbers Flashcards

1
Q

let billion = 1e9; //

A

1 billion, literally: 1 and 9 zeroes

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

let mсs = 0.000001;

another way of writing this

let mсs =

A

1e-6;

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

round number down

A

math.floor

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

round number up

A

math.ceil

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

Rounds to the nearest integer

A

math.round

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

The method ________rounds the number to n digits after the point and returns a string representation of the result.

A

toFixed(n)

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

let sum = 0.1 + 0.2;
alert( sum ); // returns

A

.300000000004

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

the most reliable method is to round the result with the help of a method

A

toFixed(n):

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

let sum = 0.1 + 0.2;
alert( sum.toFixed(2) ); // “0.30”

returns a string. How can you return an interger?

A

alert( +sum.toFixed(2) );

add plus sign.

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

alert( +”100px” ); // returns and why?

A

NaN

Numeric conversion using a plus + or Number() is strict.

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

They “read” a number from a string until they can’t. In case of an error, the gathered number is returned.

A

parseInt and parseFloat

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

alert( parseFloat(‘12.5em’) ); // 12.5

A

hey “read” a number from a string until they can’t. In case of an error, the gathered number is returned. The function parseInt returns an integer, whilst parseFloat will return a floating-point number:

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

alert( parseInt(‘a123’) ); //

A

NaN, the first symbol stops the process

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

Returns a random number from 0 to 1 (not including 1).

A

math.random()

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

Returns the greatest and smallest from the arbitrary number of arguments.

A

Math.max(a, b, c…) and Math.min(a, b, c…)

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

Returns n raised to the given power.

A

Math.pow(n, power)