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
87 changes: 83 additions & 4 deletions challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 🚀🚀🚀🚀
Expand All @@ -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()


/*
Expand All @@ -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 🚀🚀🚀🚀
Expand All @@ -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")



/*
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
</head>
<body>
<h1>Check the console log for changes</h1>

<script src="challenges.js"></script>
</body>
</html>