Skip to content

Commit

Permalink
Initial Challenges solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
Walid-Berrouk committed Aug 7, 2022
0 parents commit 939b7c0
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Challenge_05.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let seasons = {
winter : ["January", "December", "February"],
spring : ["March", "April", "May"],
summer :["June", "July", "August"],
autumn : ["September", "October", "November"],

}

let month = "September"

for (const key in seasons) {
if (seasons[key].indexOf(month) != -1) {
console.log("The Season is :", key);
}
}

79 changes: 79 additions & 0 deletions Challenge_10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
var users = {
Alex: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript'],
age: 20,
isLoggedIn: false,
points: 30
},
Asab: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'Redux', 'MongoDB', 'Express', 'React', 'Node'],
age: 25,
isLoggedIn: false,
points: 50
},
Brook: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux'],
age: 30,
isLoggedIn: true,
points: 50
},
Daniel: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'Python'],
age: 20,
isLoggedIn: false,
points: 40
},
John: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'React', 'Redux', 'Node.js'],
age: 20,
isLoggedIn: true,
points: 50
},
Thomas: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'React'],
age: 20,
isLoggedIn: false,
points: 40
},
Paul: {
email: '[email protected]',
skills: ['HTML', 'CSS', 'JavaScript', 'MongoDB', 'Express', 'React', 'Node'],
age: 20,
isLoggedIn: false,
points: 40
}
}

// Solution 1
let MostSkilled = {
key : "Alex",
numSkills: users["Alex"].skills.length
}

for (const key in users) {
if (users[key].skills.length > MostSkilled["numSkills"]) {
MostSkilled = {
key : key,
numSkills: users[key].skills.length
}
}
}

console.log(MostSkilled["key"], users[MostSkilled["key"]]);

// Solution 2
// let MostSkilled = users["Alex"]

// for (const key in users) {
// if (users[key].skills.length > MostSkilled.skills.length ) {
// MostSkilled = users[key]
// }
// }

// console.log(MostSkilled);
1 change: 1 addition & 0 deletions Challenge_14.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("$" + (+(prompt("Enter The price"))).toFixed(2));
8 changes: 8 additions & 0 deletions Challenge_17.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let arr =[4, 6, 9, "Hello", 8, "a", "0", "b"]
let val = prompt("Give me the value you want to search.")

if (arr.indexOf(+(val)) != -1 || arr.indexOf(val) != -1 ) {
console.log(val, "Is in the array.");
} else {
console.log(val, "is not in the array.");
}
Empty file added Challenge_19.js
Empty file.
15 changes: 15 additions & 0 deletions Challenge_20.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let num = "493193"
let bigNum = num

let sum;

while (num.length > 1) {
sum = 0;
for (let index = 0; index < num.length; index++) {
sum += +(num[index]);
}
num = sum.toString()

}

console.log("The Digital Root of", bigNum, "is :", num)
17 changes: 17 additions & 0 deletions Ultimate_Challenge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@



let flinker = [
{
title : "Me at the Beach",
caption: "Having fun with my firends at the beach",
photo: "beachPhotos/img1.png",
likes : ["Alex", "Recim", "Paul"]
},
{
title : "What a day at my grandma house",
caption: "Why don't people see their grandparents so often ? it is so cool",
photo: "grandMaPhotos/img2.png",
likes : ["Alex", "Recim", "Paul", "Tarek", "Chemsou"]
}
]

0 comments on commit 939b7c0

Please sign in to comment.