-
-
Notifications
You must be signed in to change notification settings - Fork 265
WM4_Gary_Rogers_JS2_Week_1 #106
base: main
Are you sure you want to change the base?
Changes from all commits
d44d7da
a3e7091
c254d28
a523d68
5343fb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| topPlayers.sort(); | ||
| console.log(topPlayers); | ||
|
|
||
| /* EXPECTED RESULT | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
|
@@ -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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: |
||
| console.log(capitalCities); | ||
|
|
||
|
|
||
| /* EXPECTED RESULT | ||
|
|
||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -27,6 +23,13 @@ let student = { | |
|
|
||
| // write code here | ||
|
|
||
| let student = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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// | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
|
@@ -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'// | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = { | ||
|
|
@@ -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// | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check what is missing in the function. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,13 @@ | |
| */ | ||
|
|
||
| let student = { | ||
| // write code here | ||
| } | ||
| name: "Daniel", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,14 @@ const COUNTRY_CURRENCY_CODES = [ | |
| ]; | ||
|
|
||
| function createLookup(countryCurrencyCodes) { | ||
| // write code here | ||
| } | ||
| let currencyCodes = {}; | ||
| countryCurrencyCodes.forEach((element) => | ||
| currencyCodes[0] = element[1] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! 👍 |
||
| ) | ||
| return currencyCodes | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
| - To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js` | ||
|
|
||
| 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 | ||
| ]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use bracket notation.
Examples:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors
https://codeburst.io/javascript-quickie-dot-notation-vs-bracket-notation-333641c0f781