-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhighOrderArray.js
More file actions
128 lines (101 loc) · 2.88 KB
/
highOrderArray.js
File metadata and controls
128 lines (101 loc) · 2.88 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// console.log("hello world ");
// ["", "",""]
// [{},{},{}]
//===============FOR OF LOOP ========================================
const myArray = ["hafiz", "talha", "abdulRehman", "shamsAli", "Abdulhadi"];
// for (const item of myArray) {
// console.log(item);
// }
// const greeting = "Hello World";
// for (const word of greeting) {
// console.log(word);
// }
//Maps
//===============================MAPS======================================
const maps = new Map();
maps.set("PK", "Pakistan");
maps.set("UK", "United Kingdom");
maps.set("USA", "United State Of America");
// for (const item of maps) {
// console.log(item);
// }
// for (const [key, val] of maps) {
// console.log(`${key} :- ${val}`);
// }
const obj1 = {
name: "waseem_akram",
f_name: "M Akram",
Rollno: "BSIT51F22S021",
};
// for (const item of obj1) {
// console.log(item);
// } //object is not iteratable...
// for (const [key, val] of obj1) {
// // console.log(key, val); //also error here because obj1 is not iteratale..
// }
//===============================For IN LOOP ==================================================
const language = {
js: "javascript",
cpp: "C++",
rb: "Ruby",
Py: "Python",
};
// for (const key in language) {
// // console.log(key); //give us keys ..
// // console.log(language[key]); //give us the values of object
// // console.log(`${key} stands for ${language[key]}`);
// }
// const langArray = ["js", "py", "cpp", "swift"];
// for (const key in langArray) {
// console.log(key); //give us index
// }
// const langArray = ["js", "py", "cpp", "swift"];
// for (const key in langArray) {
// console.log(langArray[key]); //give us values on indexes just like js ,py ...
// }
// const langArray = ["js", "py", "cpp", "swift"];
// for (const [key, val] in langArray) {
// console.log(`the key is ${key} and the value is ${val}`); //undefined..
// }
// for (const product in maps) {
// console.log(product); //gives you nothing
// }
// for (const product in maps) {
// console.log(maps[product]); //gives you nothing
// }
//==========================FOR-EACH LOOP ====================================
const webSeries = ["hostel_days", "jee krda ", "imMature", "Kota-Factory"];
const favSeries = webSeries.forEach((item, index, arr) =>
console.log(item, index, arr)
);
// console.log(favSeries);
// const favSeries = webSeries.forEach((item) => console.log(item));
// const favSeries = webSeries.forEach((item) => {
// return item; // no return
// });
// const favSeries = webSeries.forEach(printme);
// function printme(item) {
// console.log(item);
// }
// console.log(favSeries);
const codingCourse2 = [
{
language: "js",
price: 2999,
},
{
language: "python",
price: 4999,
},
{
language: "java",
price: 6999,
},
{
language: "swift",
price: 12999,
},
];
codingCourse2.forEach((item) => {
console.log(item.language);
});