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

<Day-2> | Classwork on Day 2 | <Murtaza> #36

Open
wants to merge 1 commit 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
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>