Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<PR-01> | Classwork Daily Practice | <Murtaza> #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Murtaza/day1/demo1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<head>

</head>
<body>
<script>

let primitive1 = 1;
let primitive2 = 2;

let non_primitive1 = {
first_name: 'James',
last_name: 'Bond'
};

let non_primitive2 = {
first_name: 'Tony',
last_name: 'Stark'
};

let clone_non_primitive1 = non_primitive1;

// Comparision
console.log("Primitive comparision check: ", primitive1 == primitive2);
console.log("Non-primitive comparision check: ", non_primitive1 == non_primitive2);
console.log("Non-primitive comparision check: ", non_primitive1 == clone_non_primitive1);

// Operators
let num1 = 100;
let num2 = 200;

console.log(num1 - num2);
console.log(num1 + num2);
console.log(num1 == num2);
console.log(num1 <= num2);
console.log(num1 >= num2);
console.log(num1 != num2);
console.log("Initial values: num1= ", num1, " num2= ", num2);
console.log("Incrementing num1 by 1, final num1 value:", ++num1);
console.log("Decrementing num2 by 1 final num1 value:", --num2);

// Ternary Operator
let balance = 100000;

if (balance > 10000) {
console.log("Feeling rich !");
} else {
console.log("I m Broke !");
}

// The 3 line syntax can be sweetly written using ternary operator
console.log(balance > 10000 ? "Feeling rich !" : "I m Broke !");

</script>
</body>
32 changes: 32 additions & 0 deletions Murtaza/day2/arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//Declare an array which contains 5 student's marks
//find sum, min, max, and also print them all
//count of pass and fail
input_marks = [60, 30, 20, 100, 40];
i = 0;
sum_total = 0;
min_mark = 100;
max_mark = 0;
count_pass = 0;
count_fail = 0;

console.log("Input Marks:");
while (i < input_marks.length) {
sum_total += marks[i];

min_mark = marks[i] < min_mark ? marks[i] : min_mark;
max_mark = marks[i] > max_mark ? marks[i] : max_mark;

if (marks[i] > 50)
count_pass += 1;
else
count_fail += 1;

console.log(marks[i]);
i++;
}

console.log("sum Total: ", sum_total);
console.log("minimum mark achieved: ", min_mark);
console.log("maximum mark achieved: ", max_mark);
console.log("No. of Students Passed: ", count_pass);
console.log("No. of Students Failed: ", count_fail);
81 changes: 81 additions & 0 deletions Murtaza/day2/conditionals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//Conditional Statements
//top down execution


for (i=0; i<=50000; i++) {
console.log("hello");
}

condition = true;
if (condition) {
console.log("Phew the loop finally ended !");
}

/*Problem statement:
marks:
< 50 -> F
50-60 -> D
60-70 -> C
70-80 -> B
> 80 -> A

alert msgs
*/

condition1 = true;
condition2= false;
condition3 = true;

//if-else-if ladder
if (condition1) {

} else if (condition2) {

} else if (condition3) {

}

switch (choice) {
case 1: break;
case 2: break;
default: break;
}

if (condition) {
//return val1
} else {
//return val2
}

result = condition ? val1 : val2;

//--- loops
// 3 kinds:
// - for [definite]

list = ['apple', 200, 'chickoo', 'orange', 'mango'];
for ( i=0; i<5; i++) {
console.log(list[i]);
}


// - while [indefinite]
list = ['apple', 200, 'chickoo', 'orange', 'mango'];
i = 0;
while (i<5) {
console.log(list[i]);
i++;
}


// - do while [indefinite]
list = ['apple', 200, 'chickoo', 'orange', 'mango'];
i = 0;
do {
console.log(list[i]);
i++;
} while (i<5);




32 changes: 32 additions & 0 deletions Murtaza/day2/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//Declare an array which contains 5 student's marks
//find sum, min, max, and also print them all
//count of pass and fail
input_marks = [60, 30, 20, 100, 40];
i = 0;
sum_total = 0;
min_mark = 100;
max_mark = 0;
count_pass = 0;
count_fail = 0;

console.log("Input Marks:");
while (i < input_marks.length) {
sum_total += marks[i];

min_mark = marks[i] < min_mark ? marks[i] : min_mark;
max_mark = marks[i] > max_mark ? marks[i] : max_mark;

if (marks[i] > 50)
count_pass += 1;
else
count_fail += 1;

console.log(marks[i]);
i++;
}

console.log("sum Total: ", sum_total);
console.log("minimum mark achieved: ", min_mark);
console.log("maximum mark achieved: ", max_mark);
console.log("No. of Students Passed: ", count_pass);
console.log("No. of Students Failed: ", count_fail);
16 changes: 16 additions & 0 deletions Murtaza/day2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- external js file -->
<!-- <script src="./conditionals.js"></script> -->
<!-- <script src="./arrays.js"></script> -->
<script src="./functions.js"></script>
</body>
</html>