diff --git a/lab.js b/lab.js new file mode 100644 index 0000000..19a6dd3 --- /dev/null +++ b/lab.js @@ -0,0 +1,47 @@ + +//Final Challenge: Student Grade Calculator +const student = { + name: "Amani", + scores: [80, 90, 75, 100] +}; + + +function calculateAverage(scores) { + let total = 0; + + + for (let i = 0; i < scores.length; i++) { + total += scores[i]; + } + + return total / scores.length; +} + + +function getGrade(avg) { + if (avg >= 90) { + return "A"; + } else if (avg >= 80) { + return "B"; + } else if (avg >= 70) { + return "C"; + } else if (avg >= 60) { + return "D"; + } else { + return "F"; + } +} + + +const average = calculateAverage(student.scores); +const grade = getGrade(average); + + +console.log("Name:", student.name); +console.log("Average:", Math.round(average)); +console.log("Grade:", grade); + + +// I believe strings were the easiest. +// I believe objects might have been the most difficult +// \ No newline at end of file diff --git a/src/amanidrummond/Strings.js b/src/amanidrummond/Strings.js new file mode 100644 index 0000000..6fb40b8 --- /dev/null +++ b/src/amanidrummond/Strings.js @@ -0,0 +1,28 @@ +// Part 1: String Methods + +let fullName = "Amani Drummond"; + + +console.log(fullName.length); + + +console.log(fullName.toUpperCase()); + + +console.log(fullName.includes("Drummond")); + + +console.log(fullName.slice(0, 4)); + +// Mini Challenge: +function greet(name) { + return "Hello, " + name.toUpperCase() + "!"; +} + +console.log(greet("Amani")); + +// .length → Returns the number of elements in something. + +// .includes() → Checks if something contains a value. Returns true or false. + +// .slice() → Returns a portion (piece) of a string or array.