-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11.js
More file actions
49 lines (33 loc) · 853 Bytes
/
11.js
File metadata and controls
49 lines (33 loc) · 853 Bytes
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
// arrays
let emA = [];
const fruits = ['Apple', 'Mango', 'Banana']
const fevPerson = [14, 'Day', {name: "Cyber24BD", age:3}]
console.log(emA);
console.log(fruits[3]);
console.log(fevPerson[2].name);
console.log(fevPerson[2]['age']);
console.log("The Length of person :",fevPerson.length);
// method
let fruit = ['Apple', 'Mango', 'Banana']
fruit.push('Jackfruits')
fruit.unshift('Ata')
console.log(fruit);
fruit.pop()
fruit.shift()
fruit[1] = 'Orange'
console.log(fruit);
// Iterating over Arrays
for (data in fruit){
console.log(fruit[data]);
}
let loopNum = [1,2,3,4,5,6,7]
for( i = 0; i < loopNum.length; i++){
let num = loopNum[i];
if (num % 2 == 0){
console.log(num);
}
}
// foreach
console.log(" For Each");
loopNum.forEach(function(num){console.log(num + 10)})
fruit.forEach((a) => console.log(a));