Skip to content

Commit 1babc27

Browse files
Merge branch 'MontessoriVisualization:main' into main
2 parents d418bac + 6fc4aa2 commit 1babc27

2 files changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const studentScores = [
2+
10, 85, 92, 78, 8, 5, 80, 95, 88, 76
3+
];
4+
// const totalMarkSum = studentScores.reduce(function(total,curren),0)
5+
const totalMarkSum = studentScores.reduce(function(total,current){
6+
console.log("valv:",total,current)
7+
return total + current
8+
}, 0);
9+
console.log("Total Marks Sum:", totalMarkSum);
10+
//if we used for each for the same scenario
11+
let total = 0;
12+
studentScores.forEach(function(score){
13+
total += score;
14+
})
15+
console.log("Total Marks Sum using forEach:", total);
16+
17+
//fiter
18+
const passingScores = studentScores.filter(function(score){
19+
return score>=75
20+
})
21+
console.log(passingScores)
22+
const filtered=[];
23+
24+
for (const element of studentScores) {
25+
if(element>=75){
26+
filtered.push(element)
27+
28+
}
29+
30+
}
31+
console.log(filtered)
32+
33+
34+
const letslearnUsersObject= [
35+
{name:"saugat Bagale",age:23,email:"saugat@example.com"},
36+
{name:"John Doe",age:30,email:"john@example.com"},
37+
{name:"Jane Smith",age:25,email:"jane@example.com"}
38+
39+
]
40+
const userNames = letslearnUsersObject.filter(function(user){
41+
return user.age >= 25
42+
}).map(function(user){
43+
return user.age
44+
}).reduce(function(acc,user){
45+
return acc + user
46+
},0)
47+
console.log(userNames)
48+
// const userNamesFor = [];
49+
// function getUserNames(users){
50+
51+
// for (const element of letslearnUsersObject) {
52+
// userNamesFor.push(element.name)
53+
// }
54+
// return userNamesFor;
55+
// }
56+

‎getStarted/js/shortingalgo.js‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* Create a system that processes student data, calculates grades, filters results, and generates reports. It should handle real-world logic like grade calculations, filtering by criteria, and data transformations.
2+
3+
What to Build:
4+
An array of student objects, where each student has: name, marks (array of subject scores), attendance percentage
5+
Functions that:
6+
Calculate average marks and assign grades (A/B/C/D based on ranges)
7+
Filter students by criteria (e.g., "show only students with > 75 average")
8+
Find top performer and lowest scorer
9+
Check eligibility (average > 40 AND attendance > 75%)
10+
Loops to iterate through data and transform it
11+
Conditionals to apply grading rules (use switch for grade assignment or if/else for eligibility)
12+
Generate a summary report showing: total students, pass count, fail count, average class score
13+
How to Approach It:
14+
Start with data structure — Create realistic student objects with nested arrays (marks per subject)
15+
Build utility functions — Each function should do ONE thing (calculate average, assign grade, filter students)
16+
Use loops strategically — .map() mindset (though not required): transform data from one form to another
17+
Apply game logic — Use conditionals creatively (e.g., bonus points if attendance > 90%)
18+
Combine everything — Chain functions and loops to build the final report
19+
Challenge Twist (Optional):
20+
Add a pass/fail rule: If marks < 40, fail regardless of attendance
21+
Add a merit scholarship checker: Show students eligible for scholarship (average > 80 AND attendance 100)
22+
Export data to a formatted string report using template literals
23+
This project forces them to design with objects, organize logic with functions, and process data with loops — all core pillars.
24+
*/
25+
// Sample student data
26+
const students = [
27+
{ name: "Ram", marks: [85, 90, 78], attendance: 92 },
28+
{ name: "Shyam", marks: [70, 75, 80], attendance: 85 },
29+
{ name: "Hari", marks: [60, 65, 58], attendance: 80 },
30+
{ name: "Gita", marks: [30, 35, 28], attendance: 70 },
31+
{ name: "Sita", marks: [95, 98, 92], attendance: 100 }
32+
];
33+
34+
function avg(student){
35+
let totalMark=0
36+
for (let index = 0; index < student.marks.length; index++) {
37+
totalMark+=student.marks[index]
38+
}
39+
return totalMark / student.marks.length;
40+
}
41+
42+
const avgmarks =[]
43+
for(let i=0;i<students.length;i++){
44+
avgmarks.push(avg(students[i]))
45+
46+
}
47+
console.log(avgmarks)
48+
let highestMark = avgmarks[0]
49+
for(let i=0;i<avgmarks.length;i++){
50+
if(avgmarks[i]>highestMark){
51+
highestMark = avgmarks[i]
52+
}
53+
}
54+
console.log("Highest Mark:", highestMark)
55+
let lowestMark = avgmarks[0]
56+
57+
for(let i=0;i<avgmarks.length;i++){
58+
if(avgmarks[i]<lowestMark){
59+
lowestMark = avgmarks[i]
60+
}
61+
}
62+
console.log("Lowest Mark:", lowestMark)
63+
64+
const accArray=[]
65+
for (let index = 0; index < avgmarks.length; index++) {
66+
let highestMark = avgmarks[0]
67+
for(let j=0;j<avgmarks.length;j++){
68+
if(avgmarks[j]>highestMark){
69+
highestMark = avgmarks[j]
70+
}
71+
72+
}
73+
74+
accArray.push(highestMark)
75+
const index = avgmarks.indexOf(highestMark)
76+
avgmarks[index] = -1
77+
console.log(avgmarks)
78+
79+
80+
81+
}
82+
console.log("Sorted Marks:", accArray)
83+
84+

0 commit comments

Comments
 (0)