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
45 changes: 38 additions & 7 deletions arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ Expected Output:

// ✍️ Solve it here ✍️

// const inventory = ["Apple", "Bread", "Milk", "Eggs"];

// inventory.push("Oranges");
// inventory.push("Bananas");

// inventory.shift(0);

// const myinventory = inventory.with(4, "Oranges");

// console.log(inventory);

/*
Task 2: Student Attendance Checker 📚✅
Expand All @@ -40,10 +47,17 @@ Output: "Ali is present."

// ✍️ Write your function here ✍️

// const student = ["Ali", "Fatima", "Hassan", "Layla"];

// function isPresent(name) {
// if (student.includes(name)) {
// return `${name} is present.`;
// } else {
// return `${name} is absent`;
// }
// }



// console.log(isPresent("Hassan"));

/*
Task 3: Top Scorers Leaderboard 🏆⚽
Expand All @@ -67,11 +81,28 @@ Output: Sorted leaderboard with updated scores

// ✍️ Write your functions here ✍️






// const topScorers = [
// { name: "Messi", score: 5 },
// { name: "Ronaldo", score: 3 },
// { name: "Neymar", score: 4 },
// ];

// function updateScore(playerName, scoreToAd) {
// const player = topScorers.find((p) => p.name === playerName);
// if (player) {
// return (player.score += scoreToAd);
// } else {
// topScorers.push({ name: playerName, score: scoreToAd });
// }
// }

// function printLeaderboard() {
// const Sorted = [topScorers].sort((a, b) => b.score - a.score);
// }
// console.log("🏆 Leaderboard:");
// Sorted.forEach((player, index) => {
// console.log(`${index + 1}. ${player.name} - ${player.score}`)
// })

/*
STRETCH TASK: **The Ultimate Treasure Hunt** 🗺️💎🏴‍☠️
Expand Down
29 changes: 24 additions & 5 deletions callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ Expected Output:

// ✍️ Solve it here ✍️

// function sendMessage(userName, callback) {
// callback(userName);
// }

// function aniga(name) {
// console.log(`welcome, ${name}!`);
// }

// sendMessage("Amina", aniga);

/*
Task 2: Temperature Checker 🌡️🌡️🌡️🌡️


You are creating a temperature monitoring system. Write a function called `checkTemperature` that:
1. Takes a temperature value and a callback function as arguments.
Y1. Takes a temperature value and a callback function as arguments.
2. The callback function should evaluate whether the temperature is "Hot", "Warm", or "Cold" based on the following:
- "Hot" if the temperature is above 30.
- "Warm" if the temperature is between 15°C and 30.
Expand All @@ -43,13 +49,26 @@ checkTemperature(35, theCallBackFunction);
Expected Output:
- "35°C is Hot."
- "22°C is Warm."
- "10°C is Cold."
- "10°C is Cold."ou are creating a temperature monitoring system. Write a function called `checkTemperature` that:

*/

// ✍️ Solve it here ✍️



// function evaluateTemperature(temperature) {
// if (temperature > 30) {
// console.log(`${temperature}°C is hot`);
// } else if (temperature >= 15 && temperature <= 30) {
// console.log(`${temperature}°C is warm`);
// } else {
// console.log(`${temperature}°C is cold.`);
// }
// }

// function checkTemperature(temperature, callback) {
// callback(temperature);
// }
// checkTemperature(10, evaluateTemperature);

/*
STRETCH: Task 3: Quiz Evaluator 📚📚📚📚
Expand Down
45 changes: 43 additions & 2 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ Expected Output:

// ✍️ Solve it here ✍️



// const gamerProfile = {
// username: "ShadowSlayer",
// level: 5,
// isOnline: false,
// };

// function updateOnlineStatus(profile, status) {
// profile.isOnline = status;
// console.log(`${profile.username} is now ${status ? "online" : "offline"}.`);
// }

// updateOnlineStatus(gamerProfile, true);
/*
Task 2: Dress Inventory Checker 👗 👗 👗 👗 👗

Expand Down Expand Up @@ -64,7 +74,21 @@ Expected Output:

// ✍️ Solve it here ✍️

// const dress = {
// name: "Evening Gown",
// size: "M",
// inStock: true,
// };

// function checkAvailability(dress) {
// if (dress.inStock) {
// console.log(`${dress.name} is available in size ${dress.size}.`);
// } else {
// console.log(`${dress.name} is out stock.`);
// }
// }

// checkAvailability(dress);

/*
Task 3: Supercar Feature Adder 🚗 🚗 🚗 🚗
Expand Down Expand Up @@ -104,3 +128,20 @@ Features:
*/

// ✍️ Solve it here ✍️

// const supercar = {
// model: "Ferrari SF90",
// price: 500000,
// features: {
// color: "Red",
// },
// };

// function addFeature(supercar, featureName) {
// supercar.features[featureName] = true;
// console.log(`${featureName} has been added to ${supercar.model}`);
// }

// addFeature(supercar, "turbo");

// console.log(supercar);