From 2427a7d7f94910b4ef11388e9a03a37796b996c3 Mon Sep 17 00:00:00 2001 From: Sundus Hussein Date: Mon, 10 Nov 2025 18:50:45 -0800 Subject: [PATCH] finished assigment --- challenges.js | 87 ++++++++++++++++++++++++++++++++++++++++++++++++--- index.html | 2 +- 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/challenges.js b/challenges.js index 9813c94..0b3f1c2 100644 --- a/challenges.js +++ b/challenges.js @@ -18,12 +18,28 @@ Output: "The late fee is $2.50." // ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️ +function calculateLateFee() { + const OverdueDays = prompt("please enter the number of overdue days") + const FeePerDay = 0.25 + const LateFee = OverdueDays * FeePerDay + + console.log(`The late fee is $${LateFee}`) +} +calculateLateFee() // Extra Task: // - Convert the function into a function expression. +const calculateLateFee = function (){ + const OverdueDays = prompt("please enter the number of overdue days") + const FeePerDay = 0.25 + const LateFee = OverdueDays * FeePerDay + + console.log(`The late fee is $${LateFee}`) +} +calculateLateFee() /* Task 2 : Favorite Color Finder 🚀🚀🚀🚀 @@ -45,11 +61,45 @@ Output: "Red: You are passionate and bold." // ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️ - +function FindColorMeaning() { +const color = prompt("put your favourite color here") +const favouriteColor = color +const YourFavouriteColor = favouriteColor * color +if (color === "Blue") { + console.log("You love calm and peace.") +} else if (color === "Red") { + console.log("You are passionate and bold") +} else if (color === "green") { + console.log("You are connected to nature.") +} else if (color === "yellow") { + console.log("You radiate happiness and energy") +} else { + console.log("That's a unique choice!") +} +} + +FindColorMeaning() // Extra Task: -// - Rewrite the function using an arrow function. - +// - Rewrite the function using an arrow function. + +const FindColorMeaning = () => { +const color = prompt("put your favourite color here") +const favouriteColor = color +const YourFavouriteColor = favouriteColor * color +if (color === "Blue") { + console.log("You love calm and peace.") +} else if (color === "Red") { + console.log("You are passionate and bold") +} else if (color === "green") { + console.log("You are connected to nature.") +} else if (color === "yellow") { + console.log("You radiate happiness and energy") +} else { + console.log("That's a unique choice!") +} +} +FindColorMeaning() /* @@ -68,11 +118,20 @@ Output: "Case #12345: John Doe's case is now logged." // ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️ - +function logCase(casenumber, clientname){ +console.log(`case ${casenumber} ${clientname} 's case is now logged`) +} +logCase(12345, "John doe") +*/ // Extra Task: // - Rewrite the function as an arrow function. +const logcase = (casenumber,clientname) => { +console.log(`case ${casenumber} ${clientname} 's case is now logged`) +} +logcase(12345, "John doe") + /* Task 4 : Attendance Tracker 🚀🚀🚀🚀 @@ -94,11 +153,31 @@ Output: "Amina is present." // ✍️ ✍️ ✍️ ✍️ Write the function here ✍️ ✍️ ✍️ ✍️ + const markAttendance = (name, ispresent) => { + if (ispresent == true){ + console.log(`${name} is present.`) + } else { + console.log(`${name} is absent`) + } + } + +markAttendance("amina", "ispresent") + // Extra Task: // - Convert the function into a function expression. +const markAttendance = function(name, ispresent){ +if (ispresent == true){ + console.log(`${name} is present.`) + } else { + console.log(`${name} is absent`) + } +} + +markAttendance("amina", "ispresent") + /* diff --git a/index.html b/index.html index a56d8b1..f035797 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,6 @@

Check the console log for changes

- +