Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
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
4 changes: 2 additions & 2 deletions 1-exercises/A-accessing-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ let dog = {
Log the name and breed of this dog using dot notation.
*/

let dogName; // complete the code
let dogBreed; // complete the code
let dogName=dog.name; // complete the code
let dogBreed=dog.breed; // complete the code

console.log(`${dogName} is a ${dogBreed}`);

Expand Down
2 changes: 1 addition & 1 deletion 1-exercises/A-accessing-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let capitalCities = {
*/

let myCountry = "UnitedKingdom";
let myCapitalCity; // complete the code
let myCapitalCity=capitalCities[myCountry]; // complete the code

console.log(myCapitalCity);

Expand Down
3 changes: 2 additions & 1 deletion 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ let basketballTeam = {
*/

// write code here
let playerNames = basketballTeam.topPlayers.sort().join("\r\n"); ;


console.log(playerNames );
/* EXPECTED RESULT

Dennis Rodman
Expand Down
3 changes: 3 additions & 0 deletions 1-exercises/B-setting-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ let capitalCities = {
*/

// write code here
capitalCities.UnitedKingdom.population=8980000;
capitalCities.China.population=21500000;
capitalCities.Peru={name : "Lima",population:9750000};

console.log(capitalCities);

Expand Down
5 changes: 4 additions & 1 deletion 1-exercises/B-setting-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ let student = {
*/

// write code here

student["attendance"]=90;
/*
- Write an "if" statement that changes the value of hasPassed to true
if the student has attendance that is equal or greater than 90
AND
exam score is above 60.
- Use bracket notation to change the value of hasPassed
*/
if(student.attendance>=90 && student.examScore>60){
student["hasPassed"] = true;
}

// write code here

Expand Down
6 changes: 3 additions & 3 deletions 1-exercises/C-undefined-properties/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let car = {
yearsOld: 8,
};

console.log(car["colour"]);
console.log(car["colour"]);//the colour property is not define in car object

// Example 2
function sayHelloToUser(user) {
Expand All @@ -25,7 +25,7 @@ let user = {
name: "Mira"
};

sayHelloToUser(user);
sayHelloToUser(user);//user object has name as a property and in sayHello function it just log firstname from user object that is not defined

// Example 3
let myPet = {
Expand All @@ -35,4 +35,4 @@ let myPet = {
},
};

console.log(myPet.getName());
console.log(myPet.getName());//the object function doesn't return the value
5 changes: 4 additions & 1 deletion 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

let student = {
// write code here
}
getName : function (name){
console.log(`Studet name :${name}`);
},
};

student.getName("Daniel");

Expand Down
9 changes: 8 additions & 1 deletion 2-mandatory/1-recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@
You should write and log at least 5 recipes
*/

// write code here
// write code here
const Recipe ={
title : "fish",
serves : 4,
ingredients : ["fish","rice"],
};

console.log(`${Recipe.title}\n Serves :${Recipe.serves}\n Ingredients:\n${(Recipe.ingredients).join("\t\n")}`);
7 changes: 7 additions & 0 deletions 2-mandatory/2-currency-code-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
return countryCurrencyCodes.reduce(function(arr1,arr2){
arr1[arr2[0]]=arr2[1];
return arr1;
}, {});



}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
7 changes: 6 additions & 1 deletion 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ let pantry = {
};

function createShoppingList(recipe) {
// write code here
let concatPantry = (pantry.fridgeContents).concat(pantry.cupboardContents);
let absence =(recipe.ingredients).filter((e)=>!concatPantry.includes(e));
return recipe={
name:recipe.name,
items :absence,
};
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
15 changes: 14 additions & 1 deletion 2-mandatory/4-restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ const MENU = {

let cashRegister = {
// write code here
}
orderBurger: function (balance) {
if (balance >= MENU.burger) {
balance = balance - MENU.burger;
return balance;
} else return balance;
},

orderFalafel: function (balance) {
if (balance >= MENU.falafel) {
balance = balance - MENU.falafel;
return balance;
} else return balance;
},
};

/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js`
Expand Down
15 changes: 11 additions & 4 deletions 3-extra/1-count-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
*/

function countWords(string) {
const wordCount = {};

// write code here

const wordCount = { };
let stringArray = string.split(" ");
if (string.length != 0) {
for (let word of stringArray) {
if (word in wordCount) {
wordCount[word] = wordCount[word] + 1;
} else {
wordCount[word] = 1;
}
}
}
return wordCount;
}

Expand Down