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
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
40 changes: 37 additions & 3 deletions arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Expected Output:
// ✍️ Solve it here ✍️


const inventory = ["Apples", "Bread", "Milk", "Eggs"];
inventory.push("Oranges" , "Bananas")
inventory.shift()
console.log(inventory)




Expand All @@ -40,10 +45,19 @@ Output: "Ali is present."

// ✍️ Write your function here ✍️

const students = ["Ali", "Fatima", "Hassan", "Layla"];

const isPresent = (name) => {
if(students.includes(name)) {
return `${name} is present`
}
else {
return `${name} is absent`
}



}
console.log(isPresent("Ali"))
console.log(isPresent("Mohammed"))

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

// ✍️ Write your functions here ✍️


const topScorers = [
{ name: "Messi", score: 5 },
{ name: "Ronaldo", score: 3 },
{ name: "Neymar", score: 4 }
];
const updateScore = (playerName , goalScore) => {
for (let i = 0; i <= topScorers.length; i++) {
if (topScorers[i].name === playerName) {
return score + goalScore
}
else {
topScorers.push( {name: playerName, score: goalScore} )
}
}
}
const printLeaderboard = () => {
const sorted = topScorers.reverse()
console.log(sorted)
}
updateScore("Neymar" , 2)
printLeaderboard()



Expand Down
28 changes: 23 additions & 5 deletions callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ Expected Output:

// ✍️ Solve it here ✍️




const sendMessage = (userName, cb ) => {
return cb(userName)
}

const theCallBackFunction = (userName) => {
console.log(`Welcome, ${userName}`)
}
sendMessage("Amina", theCallBackFunction);
/*
Task 2: Temperature Checker 🌡️🌡️🌡️🌡️

Expand Down Expand Up @@ -49,8 +54,21 @@ Expected Output:
// ✍️ Solve it here ✍️




const checkTemperature = (tempvalue, cb) => {
return cb (tempvalue)
}
const callbackFunction = (tempvalue) => {
if (tempvalue > 30) {
console.log(`${tempvalue} is Hot `)
}
else if (tempvalue >= 15 && tempvalue <= 30 ) {
console.log(`${tempvalue} is warm `)
}
else {
console.log(`${tempvalue} is warm `)
}
}
checkTemperature(35, callbackFunction)
/*
STRETCH: Task 3: Quiz Evaluator 📚📚📚📚

Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<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>
35 changes: 30 additions & 5 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@ Expected Output:
*/

// ✍️ Solve it here ✍️



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

};
const updateOnlineStatus = (gamerProfile, status) => {
if(status) {
console.log(`${gamerProfile.username} is now online`)
}
else {
console.log(`${gamerProfile.username} is offline`)
}
}
updateOnlineStatus(gamerProfile, true)

/*
Task 2: Dress Inventory Checker 👗 👗 👗 👗 👗

Expand Down Expand Up @@ -63,8 +76,20 @@ Expected Output:
*/

// ✍️ Solve it here ✍️


const dress = {
name: "Evening Gown",
size: "M",
inStock: true
};
const checkAvailability = (dress) => {
if(dress.inStock) {
console.log(`${dress.name} is available in size ${dress.size}.`)
}
else {
console.log(`${dress.name} is not available in size ${dress.size}.`)
}
}
checkAvailability(dress);

/*
Task 3: Supercar Feature Adder 🚗 🚗 🚗 🚗
Expand Down