diff --git a/arrays.js b/arrays.js index 37faed2..4877a43 100644 --- a/arrays.js +++ b/arrays.js @@ -16,6 +16,14 @@ Expected Output: // ✍️ Solve it here ✍️ +const inventory = ["Apples", "Bread", "Milk", "Eggs"]; + +inventory.push("Oranges","Bananas"); +console.log(inventory.shift()) + + +console.log(inventory) + @@ -40,7 +48,17 @@ Output: "Ali is present." // ✍️ Write your function here ✍️ +const students = ["Ali", "Fatima", "Hassan", "Layla"]; + +function isPresent(name) { + if (students.includes(name)) { + return `${name} is present.` + } else { + return `${name} is absent.`; + } +} +console.log(isPresent("Ali")) @@ -68,11 +86,6 @@ Output: Sorted leaderboard with updated scores // ✍️ Write your functions here ✍️ - - - - - /* STRETCH TASK: **The Ultimate Treasure Hunt** 🗺️💎🏴☠️ diff --git a/callbacks.js b/callbacks.js index 3fadb3f..3c2cf00 100644 --- a/callbacks.js +++ b/callbacks.js @@ -18,7 +18,12 @@ Expected Output: // ✍️ Solve it here ✍️ - +function sendMessage(username,cb) { + return cb(`Welcome, ${username}`) + } +sendMessage("Amina", theCallBackFunction) +function theCallBackFunction(welcome){ +console.log(welcome)} /* @@ -48,7 +53,20 @@ Expected Output: // ✍️ Solve it here ✍️ - +function checkTemperature(tempv,cb){ + +return cb(tempv)} +function theCallbackFunction(tempv){ + if (tempv >30){ + console.log("hot") + } + else if (tempv >= 15 && tempv <= 30){ + console.log("warm")} + else { + console.log("cold") + } +} +checkTemperature(35,theCallbackFunction) /* diff --git a/index.html b/index.html index 1104b64..b3efd6a 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,10 @@