Skip to content

Commit 45af657

Browse files
committed
highOrderArray done
1 parent 5e3ed4c commit 45af657

File tree

4 files changed

+284
-0
lines changed

4 files changed

+284
-0
lines changed

03_basics/controFlow.js

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//If condition
2+
3+
if (true) {
4+
//console.log("this is true statement");
5+
}
6+
7+
if (false) {
8+
console.log("this will not run");
9+
}
10+
if (2 == "2") {
11+
//console.log("is it true");
12+
}
13+
14+
const userLoggedIn = true;
15+
const userLoggedInGmail = true;
16+
17+
if (userLoggedIn && userLoggedInGmail) {
18+
//console.log("Congratulations for successfully login");
19+
}
20+
21+
//<,>,<= ,>= ,!= , ==,=== && || ? ??
22+
23+
// const marks = 81;
24+
// if (marks >= 80 && marks <= 100) {
25+
// console.log("congratulations on gettng A+ grade");
26+
// } else if (marks >= 50 && marks < 80) {
27+
// console.log("You've passed");
28+
// } else {
29+
// console.log("you're fail because you are in university of sargodha");
30+
// }
31+
32+
// const month = 3;
33+
34+
// switch (month) {
35+
// case 1:
36+
// console.log("jan");
37+
// break;
38+
39+
// case 2:
40+
// console.log("feb");
41+
// break;
42+
// default:
43+
// console.log("march");
44+
// break;
45+
// }
46+
47+
// const userEmail = "mw5667155@gmail.com";
48+
// if (userEmail) {
49+
// console.log("you've loggedIn");
50+
// } else {
51+
// console.log("Go first,login");
52+
// }
53+
54+
// const userEmail = ""; //false
55+
// if (userEmail) {
56+
// console.log("you've loggedIn");
57+
// } else {
58+
// console.log("Go first,login");
59+
// }
60+
61+
// const userEmail = []; //true
62+
// if (userEmail) {
63+
// console.log("you've loggedIn");
64+
// } else {
65+
// console.log("Go first,login");
66+
// }
67+
68+
// const userEmail = {}; //true
69+
// if (userEmail) {
70+
// console.log("you've loggedIn");
71+
// } else {
72+
// console.log("Go first,login");
73+
// }
74+
75+
// const userEmail = " "; //true
76+
// if (userEmail) {
77+
// console.log("you've loggedIn");
78+
// } else {
79+
// console.log("Go first,login");
80+
// }
81+
82+
//Falsy values
83+
84+
//false , 0 ,-0, bigInt 0n , "" , null ,undefined , NaN ;
85+
86+
//Truthy values
87+
88+
// "0" , "false" , " " , [] , {} ,function(){} ,
89+
90+
const arr = [];
91+
92+
// if (arr.length === 0) {
93+
// console.log("Array is Empty");
94+
// } else {
95+
// console.log("Array is not Empty");
96+
// }
97+
98+
// const myObj = {};
99+
// if (Object.keys(myObj) === 0) {
100+
// console.log("object is empty");
101+
// } else {
102+
// console.log("object is not empty");
103+
// }
104+
105+
// false == 0 => true
106+
// false == '' => true
107+
// 0 == '' => true
108+
109+
//Nulish coalescing operator (??) : null,undefined
110+
let val1;
111+
// val1 = null ?? 5;
112+
// val1 = undefined ?? 5;
113+
// val1 = null ?? undefined; //undefined ..
114+
val1 = null ?? 10 ?? 20;
115+
//console.log(val1);
116+
117+
//Terniary Operator..
118+
119+
// condition?true : false
120+
let a = 3;
121+
a > 3 ? console.log("yes it is true ") : console.log("it is false ");

04_iterations/for_loop.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// console.log("hello world");
2+
3+
// for (let i = 0; i < 10; i++) {
4+
// console.log(i);
5+
// }
6+
7+
// for (let i = 0; i < 10; i++) {
8+
// if (i == 5) {
9+
// console.log("this is on 5");
10+
// continue;
11+
// }
12+
// console.log(i);
13+
// }
14+
15+
// for (let i = 0; i < 10; i++) {
16+
// if (i == 5) {
17+
// console.log("this is on 5");
18+
// break;
19+
// }
20+
// console.log(i);
21+
// }
22+
// const myArray = ["waseem", "hafiz", "talha"];
23+
// for (let i = 0; i < myArray.length; i++) {
24+
// console.log(myArray[i]);
25+
// }
26+
27+
// for (let i = 1; i <= 10; i++) {
28+
// console.log(`Outer Loop is ${i}`);
29+
// for (let j = 1; j <= 10; j++) {
30+
// console.log(`outerloop ${i} and inner loop ${j}`);
31+
// }
32+
// }
33+
34+
// for (let i = 1; i <= 10; i++) {
35+
// // console.log(`Outer Loop is ${i}`);
36+
// for (let j = 1; j <= 10; j++) {
37+
// console.log(`${i} * ${j} = ${i * j} `);
38+
// }
39+
// console.log("\n");
40+
// } //Table from one to 10 ...;

04_iterations/highOrderArray.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// console.log("hello world ");
2+
3+
// ["", "",""]
4+
// [{},{},{}]
5+
6+
//===============FOR OF LOOP ========================================
7+
8+
const myArray = ["hafiz", "talha", "abdulRehman", "shamsAli", "Abdulhadi"];
9+
// for (const item of myArray) {
10+
// console.log(item);
11+
// }
12+
13+
// const greeting = "Hello World";
14+
// for (const word of greeting) {
15+
// console.log(word);
16+
// }
17+
18+
//Maps
19+
//===============================MAPS======================================
20+
21+
const maps = new Map();
22+
maps.set("PK", "Pakistan");
23+
maps.set("UK", "United Kingdom");
24+
maps.set("USA", "United State Of America");
25+
26+
// for (const item of maps) {
27+
// console.log(item);
28+
// }
29+
30+
// for (const [key, val] of maps) {
31+
// console.log(`${key} :- ${val}`);
32+
// }
33+
34+
const obj1 = {
35+
name: "waseem_akram",
36+
f_name: "M Akram",
37+
Rollno: "BSIT51F22S021",
38+
};
39+
// for (const item of obj1) {
40+
// console.log(item);
41+
// } //object is not iteratable...
42+
43+
// for (const [key, val] of obj1) {
44+
// // console.log(key, val); //also error here because obj1 is not iteratale..
45+
// }
46+
47+
//===============================For IN LOOP ==================================================
48+
49+
const language = {
50+
js: "javascript",
51+
cpp: "C++",
52+
rb: "Ruby",
53+
Py: "Python",
54+
};
55+
56+
// for (const key in language) {
57+
// // console.log(key); //give us keys ..
58+
// // console.log(language[key]); //give us the values of object
59+
// // console.log(`${key} stands for ${language[key]}`);
60+
// }
61+
62+
// const langArray = ["js", "py", "cpp", "swift"];
63+
// for (const key in langArray) {
64+
// console.log(key); //give us index
65+
// }
66+
67+
// const langArray = ["js", "py", "cpp", "swift"];
68+
// for (const key in langArray) {
69+
// console.log(langArray[key]); //give us values on indexes just like js ,py ...
70+
// }
71+
72+
// const langArray = ["js", "py", "cpp", "swift"];
73+
// for (const [key, val] in langArray) {
74+
// console.log(`the key is ${key} and the value is ${val}`); //undefined..
75+
// }
76+
77+
// for (const product in maps) {
78+
// console.log(product); //gives you nothing
79+
// }
80+
// for (const product in maps) {
81+
// console.log(maps[product]); //gives you nothing
82+
// }
83+
84+
//==========================FOR-EACH LOOP ====================================
85+
86+
const webSeries = ["hostel_days", "jee krda ", "imMature", "Kota-Factory"];
87+
88+
const favSeries = webSeries.forEach((item, index, arr) =>
89+
console.log(item, index, arr)
90+
);
91+
console.log(favSeries);
92+
93+
// const favSeries = webSeries.forEach((item) => console.log(item));
94+
95+
// const favSeries = webSeries.forEach((item) => {
96+
// return item; // no return
97+
// });
98+
99+
// const favSeries = webSeries.forEach(printme);
100+
// function printme(item) {
101+
// console.log(item);
102+
// }
103+
// console.log(favSeries);

04_iterations/while_doWhile.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// console.log("hello world ");
2+
3+
// let i = 0;
4+
// while (i < 10) {
5+
// console.log(i);
6+
// i++;
7+
// }
8+
9+
// let i = 0;
10+
// do {
11+
// console.log(i);
12+
// i++;
13+
// } while (i < 10);
14+
15+
const Heros = ["spiderman", "Ironman", "Monkeyman"];
16+
let i = 0;
17+
while (i < Heros.length) {
18+
console.log(Heros[i]);
19+
i++;
20+
}

0 commit comments

Comments
 (0)