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
23 changes: 18 additions & 5 deletions arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)




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



Expand Down Expand Up @@ -68,11 +86,6 @@ Output: Sorted leaderboard with updated scores
// ✍️ Write your functions here ✍️







/*
STRETCH TASK: **The Ultimate Treasure Hunt** 🗺️💎🏴‍☠️

Expand Down
22 changes: 20 additions & 2 deletions callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}


/*
Expand Down Expand Up @@ -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)


/*
Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<body>
<h1>Look at the console to see the results</h1>


<!-- Before starting, add the javascript files in this html fie -->
<script src="arrays.js"></script>
<script src="callbacks.js"></script>
<script src="objects.js"></script>
</body>
</html>
43 changes: 43 additions & 0 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,22 @@ Expected Output:

// ✍️ Solve it here ✍️

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

function updateOnlineStatus(gamerProfile, status) {
gamerProfile.isOnline = status;

if (status) {
console.log(`${gamerProfile.username} is now online.`);
} else {
console.log(`${gamerProfile.username} is now offline.`);
}
}
updateOnlineStatus(gamerProfile, true)
/*
Task 2: Dress Inventory Checker 👗 👗 👗 👗 👗

Expand Down Expand Up @@ -64,6 +78,21 @@ Expected Output:

// ✍️ Solve it here ✍️

const dress= {
name: "EveningGown",
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 of stock.`)
}
}
checkAvailability (dress)



/*
Expand Down Expand Up @@ -104,3 +133,17 @@ 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("Features:");