-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNote.txt
65 lines (65 loc) · 1.63 KB
/
Note.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Javascript Looping
=>While Loop
It loops through a block of code as long as the specified condition is true.
syntax:
while(condition)
{
//block of code (code will execute until condition is true)
}
Examples:
var countdown = 10;
var i =0;
while(i < countdown)
{
console.log(countdown);
countdown--;
}
***-----------------------------------****
=>Do-While Loop
It will execute the body first then checks the condition satisfies or not.
syntax:
do{
//block of code
}while(condition)
Example:
let count =0;
do{
console.log(count);
count ++;
}while(count<5)
***-----------------------------------****
Javascript Math Methods
=>Math.floor (It takes base values and if it is negative value then it takes next nearest integer)
console.log(Math.floor(5.9));//5
console.log(Math.floor(-4.9));//-5
=>Math.ceil
console.log(Math.ceil(5.1));//6
console.log(Math.ceil(-4.9));//-4
=>Math.round
console.log(Math.round(5.4));//5
console.log(Math.round(6.6));//7
=>Math.sqrt
console.log(Math.sqrt(0));//
console.log(Math.sqrt(-2));//
console.log(Math.sqrt(25));//
=>Math.cbrt
console.log(Math.cbrt(27));
console.log(Math.cbrt(125));
console.log(Math.cbrt(-125));
==>Math.abs
console.log(Math.abs(-4.5));
console.log(Math.abs(-4.8));
console.log(Math.abs(-4.4));
==>Math.trunc
console.log(Math.trunc(4.5));
console.log(Math.trunc(4.8));
console.log(Math.trunc(4.4));
==>Math.min
console.log(Math.min(3,25,49,3.28));
==>Math.max
console.log(Math.max(3,25,49,3.28));
==>Math.pow
console.log(Math.pow(2,5));
//2*2*2*2*2
==>Math.random(Generates a random number from 0 to 9 with decimals)
console.log(Math.random()*10);