-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11-arrays-and-loops.html
More file actions
100 lines (95 loc) · 2.33 KB
/
11-arrays-and-loops.html
File metadata and controls
100 lines (95 loc) · 2.33 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html>
<head>
<title>Arrays and Loops</title>
<style>
</style>
</head>
<body>
<script>/*
const myArray = [10, 20, 30];
console.log(myArray);
console.log(myArray[1]);
//gives the position in the array
//nimber 1 represents the index
// and a position in the array
// index 0,1,2,3,4,5,6,7,8,9 and so on
myArray[0] = 99;
console.log(myArray);
[1, 'hello', true, {name: 'socks'}, [1, 2]];
console.log(typeof [1, 2]);
console.log( Array.isArray([1,2]));
console.log(myArray.length);
myArray.push(100);
console.log(myArray);
myArray.splice(0, 1);
console.log(myArray);
*/
/*let i = 1;
while (i <= 5) {
console.log(i);
i ++;
}
for (let i = 1; i <= 5; i++) {
console.log(i)
}
let randomNumber = 0;
while(randomNumber < 0.5) {
randomNumber = Math.random();
}
console.log(randomNumber);
*//*
const TodoList = {
'make money',
'Grow old',
'Make heaven',
}
for(let i = 0; index <= TodoList - 1; i++) {
const value = TodoList[i];
console.log(value);
}// looping through an array
*/
/*const nums = [1, 1, 3];
const total = 0; //acumilator varaible
for (let i = 0; i < num.length; i++) {
const num = nums[i];
total += num;
} //acumilator patern
console.log(total);
const numsDoubled = [];
for (let i = 0; i < nums.length; i++) {
const num = num[i];
numsDoubled.push(num * 2);
}*/
const array1 = [1, 2, 3];
const array2 = array1.slice();
array2.push(4);
console.log(array1);
console.log(array2);
const [fistValue, secondValue] = [1, 2, 3];
for (let i = 1; i <= 10; i++) {
if (i % 3 === 0) {
continue;
}
if (i = 8) {
break;
}
}
let i = 1;
while (i <= 10) {
if (i % 3 === 0) {
i++;
continue;
}
console.log(i);
i++;
}
function do
const muns = [1, 1, 3];
const numsDoubled = [];
for (let i = 0; i < nums.length; i++) {
const num = num[i];
numsDoubled.push(num * 2);
</script>
</body>
</html>