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
75 changes: 75 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

hidden = [".config"]
run = "npm run start"

[[hints]]
regex = "Error \\[ERR_REQUIRE_ESM\\]"
message = "We see that you are using require(...) inside your code. We currently do not support this syntax. Please use 'import' instead when using external modules. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)"

[nix]
channel = "stable-21_11"

[env]
XDG_CONFIG_HOME = "/home/runner/.config"
PATH = "/home/runner/$REPL_SLUG/.config/npm/node_global/bin:/home/runner/$REPL_SLUG/node_modules/.bin"
npm_config_prefix = "/home/runner/$REPL_SLUG/.config/npm/node_global"

[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config"]

[packager]
language = "nodejs"

[packager.features]
packageSearch = true
guessImports = true
enabledForHosting = false

[unitTest]
language = "nodejs"

[languages.javascript]
pattern = "**/{*.js,*.jsx,*.ts,*.tsx}"

[languages.javascript.languageServer]
start = [ "typescript-language-server", "--stdio" ]

[debugger]
support = true

[debugger.interactive]
transport = "localhost:0"
startCommand = [ "dap-node" ]

[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"

[debugger.interactive.initializeMessage.arguments]
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true

[debugger.interactive.launchMessage]
command = "launch"
type = "request"

[debugger.interactive.launchMessage.arguments]
args = []
console = "externalTerminal"
cwd = "."
environment = []
pauseForSourceMap = false
program = "./index.js"
request = "launch"
sourceMaps = true
stopOnEntry = false
type = "pwa-node"
12 changes: 6 additions & 6 deletions 1-exercises/A-accessing-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
*/

let dog = {
breed: "Dalmatian",
name: "Spot",
isHungry: true,
happiness: 6
breed: "Dalmatian", //string
name: "Spot", //string
isHungry: true, //Boolean
happiness: 6 //number
};

/*
You can access the values of each property using dot notation.
Log the name and breed of this dog using dot notation.
*/

let dogName; // complete the code
let dogBreed; // complete the code
let dogName = "Spot"
let dogBreed = "Dalmation"

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 = "London"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


console.log(myCapitalCity);

Expand Down
4 changes: 3 additions & 1 deletion 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ let basketballTeam = {
- console.logs the name of each player on a new line
*/

// write code here

let topPlayers = ["Michael Jordan", "Scottie Pippen", "Dennis Rodman"];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not copy the code but use the dot notation or bracket notation to retrieve values from the object.
Please check this:
https://codeburst.io/javascript-quickie-dot-notation-vs-bracket-notation-333641c0f781
https://syllabus.codeyourfuture.io/js-core-2/week-1/lesson#objects

topPlayers.sort();
console.log(topPlayers);

/* EXPECTED RESULT

Expand Down
42 changes: 33 additions & 9 deletions 1-exercises/B-setting-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
You can also change the value assigned to a property using dot notation.
*/

let capitalCities = {
UnitedKingdom: {
name: "London",
population: 20,
},
China: {
name: "Beijing",
}
};
// let capitalCities = {
// UnitedKingdom: {
// name: "London",
// population: 20,
// },
// China: {
// name: "Beijing",
// population: 21500000,
// }
// Peru: {
// name: "Lima"
// population: 9750000,
// }
// };




/*
Using dot notation:
Expand All @@ -24,8 +32,24 @@ let capitalCities = {

// write code here

let capitalCities = {
UnitedKingdom: {
name: "London",
population: 20,
},
China: {
name: "Beijing",
population: 21500000,
},
Peru: {
name: "Lima",
population: 9750000,
}
};
capitalCities.UnitedKingdom = 8980000;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part related to: "Change the value of UnitedKingdom's capital city population to 8980000." You did well :)

You need to do the same way the other part of the exercise:
- Add the property for population to China's capital city and set the value to 21500000.
- Add the country "Peru" to capitalCities object.
- Add a name of "Lima" to Peru's capital city.
- Add a population of 9750000 to Peru's capital city.

Please check this: https://bobbyhadz.com/blog/javascript-add-key-value-pair-to-object

console.log(capitalCities);


/* EXPECTED RESULT

{
Expand Down
13 changes: 8 additions & 5 deletions 1-exercises/B-setting-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
You can also change the value assigned to a property using bracket notation.
*/

let student = {
name: "Reshma Saujani",
examScore: 65,
hasPassed: false
};


/*
Using bracket notation
Expand All @@ -27,6 +23,13 @@ let student = {

// write code here

let student = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use bracket notation here - the exercise needs to be done dynamically, not hard coded.

name: "Reshma Saujani",
examScore: 65,
hasPassed: true,
attendance: 90,
};

console.log(student);

/* EXPECTED RESULT
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"]); //"colour" is not defined as an object anywhere in the variable statement//
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the CYF lesson about objects: https://syllabus.codeyourfuture.io/js-core-2/week-1/lesson#objects


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

sayHelloToUser(user);
sayHelloToUser(user); //Hello in the console log is undefined, as well as 'firstName' not identified as the object 'name'//
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check one more time what parameters have the user object.


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

console.log(myPet.getName());
console.log(myPet.getName()); //has attempted to create a function element where the property should be//
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check what is missing in the function.
This is quite interesting post about it: https://stackoverflow.com/questions/17337064/does-every-javascript-function-have-to-return-a-value

9 changes: 6 additions & 3 deletions 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
*/

let student = {
// write code here
}
name: "Daniel",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please think about the object's methods as functions because basically, they are functions.
You need to finish this exercise in a dynamic way.

Please check this: https://syllabus.codeyourfuture.io/js-core-1/week-1/lesson#functions

message: function () {
return "Student name: + (name) ";
},
};

student.getName("Daniel");
console.log (student)

/* EXPECTED RESULT

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

// write code here
let recipe1 = {
name: "Pepperoni Pizza",
serves: 3,
ingredients: ["bread", "tomato sauce", "pepperoni", "cheese"],
}

let recipe2 = {
name: "chilli con carne",
serves: 5,
ingredients: ["beef", "chillies", "tomato sauce", "kidney beans"],
}

let recipe3 = {
name: "Kung Pao Chicken",
serves: 2,
ingredients: ["chicken", "peanuts", "soy sauce", "beansprouts"],
}

let recipe4 = {
name: "Indian Mixed Grill",
serves: 5,
ingredients: ["tandori chicken", "pork chops", "bell peppers", "chillies"],
}

let recipe5 = {
name: "Full English Breakfast",
serves: 1,
ingredients: ["bacon", "sausage", "fried egg", "baked beans"],
}

console.log(recipe1)
console.log(recipe2)
console.log(recipe3)
console.log(recipe4)
console.log(recipe5)
10 changes: 8 additions & 2 deletions 2-mandatory/2-currency-code-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ const COUNTRY_CURRENCY_CODES = [
];

function createLookup(countryCurrencyCodes) {
// write code here
}
let currencyCodes = {};
countryCurrencyCodes.forEach((element) =>
currencyCodes[0] = element[1]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a small thing to fix the end of the entire exercise will be done perfectly! 👍
Please think over where You can use bracket notation in the line 23.

)
return currencyCodes
};



/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js`
Expand Down
5 changes: 4 additions & 1 deletion 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ let pantry = {
cupboardContents: ["salt", "tinned tomatoes", "oregano"],
};


function createShoppingList(recipe) {
// write code here
let allItems = pantry.fridgeContents.concat(pantry.cupboardContents);
(ingredients) => combinedPantry.includes(ingredients);
return allItems;
}

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

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

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
8 changes: 8 additions & 0 deletions replit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs }: {
deps = [
pkgs.nodejs-16_x
pkgs.nodePackages.typescript-language-server
pkgs.yarn
pkgs.replitPackages.jest
];
}