Skip to content
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
49 changes: 48 additions & 1 deletion challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ Output: "The late fee is $2.50."

// ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️

function calculateLateFee() {
const overdueDays = parseInt(prompt("Enter the number of overdue days:"));
const feePerDay = 0.25;
const lateFee = overdueDays * feePerDay;
console.log(`The late fee is $${lateFee.toFixed(2)}.`);

}
calculateLateFee()

// Extra Task:
// - Convert the function into a function expression.
Expand Down Expand Up @@ -46,6 +53,23 @@ Output: "Red: You are passionate and bold."
// ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️


function findColorMeaning() {
const color = prompt("Enter your favorite color:")
if (color == "blue"){
console.log("Blue: You love calm and peace.");
} else if(color === "Red"){
console.log("Red: You are passionate and bold.");
} else if(color === "Green"){
console.log("Green: You are connected to nature.");
} else if(color === "Yellow"){
console.log("Yellow: You radiate happiness and energy.");
} else {
console.log("That's a unique choice!");
}
}
findColorMeaning()



// Extra Task:
// - Rewrite the function using an arrow function.
Expand All @@ -67,7 +91,11 @@ Output: "Case #12345: John Doe's case is now logged."
*/

// ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️
function logCase(clientName, caseNumber) {
console.log(`Case #${caseNumber}: ${clientName}'s case is now logged.`);
logCase("John Doe", 12345);

}


// Extra Task:
Expand All @@ -93,6 +121,14 @@ Output: "Amina is present."
*/

// ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️
function markAttendance(studentName, isPresent) {
if (isPresent) {
console.log(`${studentName} is present.`);
} else {
console.log(`${studentName} is absent.`);
}
}
markAttendance("Amina", true)



Expand Down Expand Up @@ -134,4 +170,15 @@ Output:
Extra Credit:
- Extend the program to accept multiple students' names and scores and generate a report for each student using a loop.
- Use an arrow function for at least one of the functions.
*/
*/
function generateReport(names) {
const studentName = prompt("Enter the student's name:");
const score1 = parseFloat(prompt("Enter the first test score:"));
const score2 = parseFloat(prompt("Enter the second test score:"));
const score3 = parseFloat(prompt("Enter the third test score:"));
const average = calculateAverage(score1, score2, score3);
const letterGrade = determineGrade(average);
console.log(`${studentName} - Average Score: ${average.toFixed(2)}, Grade: ${letterGrade}`);
}

generateReport()
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</head>
<body>
<h1>Check the console log for changes</h1>
<script src="challenges.js"></script>

</body>
</html>