-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday1.js
More file actions
18 lines (14 loc) · 689 Bytes
/
day1.js
File metadata and controls
18 lines (14 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// ! Day 1 of learning DSA in Javascript
// * create an array with 5 students names, and after that create a function which takes 2 parameters (allStudents, & studentName ) iterate over all students and find that specific studentName
// Todo: The Array data Structure we use
const students = ["Bhavishya", "Ankit", "Anurag", "Aman", "Somil"];
// Todo: This the Algorithm to solve the Problem
function findName(students, studentName) {
for (let i = 0; i < students.length; i++) {
if (studentName.toLowerCase() === students[i].toLowerCase()) {
return `Student Name Matched ${studentName}`;
}
return `Student not Found`;
}
}
console.log(findName(students, "shon"));