From d55d503e638f4060d8231b6081046237f29478fe Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 27 Apr 2020 12:29:09 +0100 Subject: [PATCH 01/37] Completed mandatory exercises --- week-1/Homework/mandatory/1-syntax-errors.js | 45 +++++++++-------- week-1/Homework/mandatory/2-logic-error.js | 25 ++++++---- .../Homework/mandatory/3-function-output.js | 48 +++++++++++-------- week-1/Homework/mandatory/4-tax.js | 40 +++++++++++----- week-1/Homework/mandatory/5-magic-8-ball.js | 42 ++++++++++++++-- 5 files changed, 134 insertions(+), 66 deletions(-) diff --git a/week-1/Homework/mandatory/1-syntax-errors.js b/week-1/Homework/mandatory/1-syntax-errors.js index b32f8a34c..5787894f7 100644 --- a/week-1/Homework/mandatory/1-syntax-errors.js +++ b/week-1/Homework/mandatory/1-syntax-errors.js @@ -1,32 +1,39 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(a b c) { - return a + b + c; +function addNumbers(a, b, c) { + return a + b + c; } -function introduceMe(name, age) -return "Hello, my name is " + name "and I am " age + "years old"; - +function introduceMe(name, age) { + return "Hello, my name is " + name + " and I am " + age + " years old"; +} function getRemainder(a, b) { - remainder = a %% b; + remainder = a % b; - // Use string interpolation here - return "The remainder is %{remainder}" + // Use string interpolation here + return `The remainder is ${remainder}`; } /* ======= TESTS - DO NOT MODIFY ===== */ function test(test_name, expr) { - let status; - if (expr) { - status = "PASSED" - } else { - status = "FAILED" - } - - console.log(`${test_name}: ${status}`) + let status; + if (expr) { + status = "PASSED"; + } else { + status = "FAILED"; + } + + console.log(`${test_name}: ${status}`); } -test("fixed addNumbers function - case 1", addNumbers(3,4,6) === 13) -test("fixed introduceMe function", introduceMe("Sonjide",27) === "Hello, my name is Sonjide and I am 27 years old") -test("fixed getRemainder function", getRemainder(23,5) === "The remainder is 3") +test("fixed addNumbers function - case 1", addNumbers(3, 4, 6) === 13); +test( + "fixed introduceMe function", + introduceMe("Sonjide", 27) === + "Hello, my name is Sonjide and I am 27 years old" +); +test( + "fixed getRemainder function", + getRemainder(23, 5) === "The remainder is 3" +); diff --git a/week-1/Homework/mandatory/2-logic-error.js b/week-1/Homework/mandatory/2-logic-error.js index e040e106a..4ea7d4b25 100644 --- a/week-1/Homework/mandatory/2-logic-error.js +++ b/week-1/Homework/mandatory/2-logic-error.js @@ -1,16 +1,15 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return word.trim(); } function getWordLength(word) { - return "word".length() + return word.length; } function multiply(a, b, c) { - a * b * c; - return; + return a * b * c; } /* ======= TESTS - DO NOT MODIFY ===== */ @@ -18,14 +17,20 @@ function multiply(a, b, c) { function test(test_name, expr) { let status; if (expr) { - status = "PASSED" + status = "PASSED"; } else { - status = "FAILED" + status = "FAILED"; } - console.log(`${test_name}: ${status}`) + console.log(`${test_name}: ${status}`); } -test("fixed trimWord function", trimWord(" CodeYourFuture ") === "CodeYourFuture") -test("fixed wordLength function", getWordLength("A wild sentence appeared!") === 25) -test("fixed multiply function", multiply(2,3,6) === 36) \ No newline at end of file +test( + "fixed trimWord function", + trimWord(" CodeYourFuture ") === "CodeYourFuture" +); +test( + "fixed wordLength function", + getWordLength("A wild sentence appeared!") === 25 +); +test("fixed multiply function", multiply(2, 3, 6) === 36); diff --git a/week-1/Homework/mandatory/3-function-output.js b/week-1/Homework/mandatory/3-function-output.js index a57e4aeca..d61f63d79 100644 --- a/week-1/Homework/mandatory/3-function-output.js +++ b/week-1/Homework/mandatory/3-function-output.js @@ -1,31 +1,39 @@ -// Add comments to explain what this function does. You're meant to use Google! +// The function returns pseudorandom number from [0,10) function getNumber() { - return Math.random() * 10; + return Math.random() * 10; } -// Add comments to explain what this function does. You're meant to use Google! +// The function concatenates 2 words together function s(w1, w2) { - return w1.concat(w2); + return w1.concat(w2); } function concatenate(firstWord, secondWord, thirdWord) { - // Write the body of this function to concatenate three words together - // Look at the test case below to understand what to expect in return + // Write the body of this function to concatenate three words together + // Look at the test case below to understand what to expect in return + return firstWord.concat(" ", secondWord, " ", thirdWord); } - /* ======= TESTS - DO NOT MODIFY ===== */ - function test(test_name, expr) { - let status; - if (expr) { - status = "PASSED" - } else { - status = "FAILED" - } - - console.log(`${test_name}: ${status}`) + let status; + if (expr) { + status = "PASSED"; + } else { + status = "FAILED"; + } + + console.log(`${test_name}: ${status}`); } - -test("concatenate function - case 1 works", concatenate('code', 'your', 'future') === "code your future") -test("concatenate function - case 2 works", concatenate('I', 'like', 'pizza') === "I like pizza") -test("concatenate function - case 3 works", concatenate('I', 'am', 13) === "I am 13") \ No newline at end of file + +test( + "concatenate function - case 1 works", + concatenate("code", "your", "future") === "code your future" +); +test( + "concatenate function - case 2 works", + concatenate("I", "like", "pizza") === "I like pizza" +); +test( + "concatenate function - case 3 works", + concatenate("I", "am", 13) === "I am 13" +); diff --git a/week-1/Homework/mandatory/4-tax.js b/week-1/Homework/mandatory/4-tax.js index 8ddbddad3..b5156d914 100644 --- a/week-1/Homework/mandatory/4-tax.js +++ b/week-1/Homework/mandatory/4-tax.js @@ -5,7 +5,10 @@ Sales tax is 20% of the price of the product */ -function calculateSalesTax() {} +function calculateSalesTax(cost) { + let salesTax = (cost * (100 + 20)) / 100; + return salesTax; +} /* CURRENCY FORMATTING @@ -17,25 +20,36 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function formatCurrency() {} - +function formatCurrency(cost) { + let twoDecimalSalexTax = calculateSalesTax(cost).toFixed(2); + return "£".concat(twoDecimalSalexTax); +} /* ======= TESTS - DO NOT MODIFY ===== */ function test(test_name, expr) { let status; if (expr) { - status = "PASSED" + status = "PASSED"; } else { - status = "FAILED" + status = "FAILED"; } - console.log(`${test_name}: ${status}`) + console.log(`${test_name}: ${status}`); } -test("calculateSalesTax function - case 1 works", calculateSalesTax(15) === 18) -test("calculateSalesTax function - case 2 works", calculateSalesTax(17.5) === 21) -test("calculateSalesTax function - case 3 works", calculateSalesTax(34) === 40.8) - -test("formatCurrency function - case 1 works", formatCurrency(15) === "£18.00") -test("formatCurrency function - case 2 works", formatCurrency(17.5) === "£21.00") -test("formatCurrency function - case 3 works", formatCurrency(34) === "£40.80") \ No newline at end of file +test("calculateSalesTax function - case 1 works", calculateSalesTax(15) === 18); +test( + "calculateSalesTax function - case 2 works", + calculateSalesTax(17.5) === 21 +); +test( + "calculateSalesTax function - case 3 works", + calculateSalesTax(34) === 40.8 +); + +test("formatCurrency function - case 1 works", formatCurrency(15) === "£18.00"); +test( + "formatCurrency function - case 2 works", + formatCurrency(17.5) === "£21.00" +); +test("formatCurrency function - case 3 works", formatCurrency(34) === "£40.80"); diff --git a/week-1/Homework/mandatory/5-magic-8-ball.js b/week-1/Homework/mandatory/5-magic-8-ball.js index 688552429..8923bcd85 100644 --- a/week-1/Homework/mandatory/5-magic-8-ball.js +++ b/week-1/Homework/mandatory/5-magic-8-ball.js @@ -42,10 +42,35 @@ My sources say no. Outlook not so good. Very doubtful. */ - +const arrayAnswers = [ + "It is certain.", + "It is decidedly so.", + "Without a doubt.", + "Yes - definitely.", + "You may rely on it.]", + "As I see it, yes.", + "Most likely.", + "Outlook good.", + "Yes.", + "Signs point to yes.", + "Reply hazy, try again.", + "Ask again later.", + "Better not tell you now.", + "Cannot predict now.", + "Concentrate and ask again.", + "Don't count on it.", + "My reply is no.", + "My sources say no.", + "Outlook not so good.", + "Very doubtful.", +]; // This should log "The ball has shaken!" // and return the answer. -function shakeBall() {} +function shakeBall() { + console.log("The ball has shaken!"); + variantAnswer = Math.round(Math.random() * 20); + return arrayAnswers[variantAnswer]; +} // The answer should come from shaking the ball let answer; @@ -55,12 +80,21 @@ let answer; // - positive // - negative // - very negative -function checkAnswer() {} +function checkAnswer(answer) { + let typeAnswer; + answer = shakeBall(); + let index = arrayAnswers.indexOf(answer); + if (index <= 4) typeAnswer = "very positive"; + else if (index <= 9) typeAnswer = "positive"; + else if (index <= 14) typeAnswer = "negative"; + else if (index <= 19) typeAnswer = "very negative"; + return typeAnswer; +} /* ======= TESTS - DO NOT MODIFY ===== */ const log = console.log; let logged; -console.log = function() { +console.log = function () { log(...arguments); logged = arguments[0]; }; From 7686570cb0d1d2b546722d5da6b4596ca89fa490 Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 27 Apr 2020 19:40:10 +0100 Subject: [PATCH 02/37] Completed extra exercises --- .../Homework/extra/1-currency-conversion.js | 20 ++++++--- week-1/Homework/extra/2-piping.js | 44 +++++++++---------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/week-1/Homework/extra/1-currency-conversion.js b/week-1/Homework/extra/1-currency-conversion.js index f96ea2e8a..f32fd4e97 100644 --- a/week-1/Homework/extra/1-currency-conversion.js +++ b/week-1/Homework/extra/1-currency-conversion.js @@ -5,7 +5,10 @@ Write a function that converts a price to USD (exchange rate is 1.4 $ to £) */ -function convertToUSD() {} +function convertToUSD(priceGBP) { + let priceUSD = priceGBP * 1.4; + return priceUSD; +} /* CURRENCY FORMATTING @@ -16,20 +19,23 @@ function convertToUSD() {} Find a way to add 1% to all currency conversions (think about the DRY principle) */ -function convertToBRL() {} +function convertToBRL(priceGBP) { + let priceBRL = priceGBP * 5.7 * 1.01; + return priceBRL; +} /* ======= TESTS - DO NOT MODIFY ===== */ function test(test_name, expr) { let status; if (expr) { - status = "PASSED" + status = "PASSED"; } else { - status = "FAILED" + status = "FAILED"; } - console.log(`${test_name}: ${status}`) + console.log(`${test_name}: ${status}`); } -test('convertToUSD function works', convertToUSD(32) === 44.8) -test('convertToBRL function works', convertToBRL(30) === 172.71) +test("convertToUSD function works", convertToUSD(32) === 44.8); +test("convertToBRL function works", convertToBRL(30) === 172.71); diff --git a/week-1/Homework/extra/2-piping.js b/week-1/Homework/extra/2-piping.js index 5f5ea4e5b..b00ce9565 100644 --- a/week-1/Homework/extra/2-piping.js +++ b/week-1/Homework/extra/2-piping.js @@ -15,44 +15,44 @@ 3. Write a more readable version of what you wrote in step 2 under the BETTER PRACTICE comment. Assign the final result to the variable goodCode */ - -function add() { - +let a, b, c, d; +function add(a, b) { + let summa = Math.round((a + b) * 10) / 10; + return summa; } -function multiply() { - +function multiply(b, c) { + return b * c; } -function format() { - +function format(d) { + return "£" + d; } -const startingValue = 2 - +const startingValue = 2; +addValue = add(startingValue, 10); +multiplayValue = multiply(addValue, 2); // Why can this code be seen as bad practice? Comment your answer. -let badCode = - +let badCode = format(multiplayValue); /* BETTER PRACTICE */ -let goodCode = - +let goodCode = format(multiplayValue); /* ======= TESTS - DO NOT MODIFY ===== */ function test(test_name, expr) { let status; if (expr) { - status = "PASSED" + status = "PASSED"; } else { - status = "FAILED" + status = "FAILED"; } - console.log(`${test_name}: ${status}`) + console.log(`${test_name}: ${status}`); } -test('add function - case 1 works', add(1,3) === 4) -test('add function - case 2 works', add(2.4,5.3) === 7.7) -test('multiply function works', multiply(2,3) === 6) -test('format function works', format(16) === "£16") -test('badCode variable correctly assigned', badCode === "£24") -test('goodCode variable correctly assigned', goodCode === "£24") \ No newline at end of file +test("add function - case 1 works", add(1, 3) === 4); +test("add function - case 2 works", add(2.4, 5.3) === 7.7); +test("multiply function works", multiply(2, 3) === 6); +test("format function works", format(16) === "£16"); +test("badCode variable correctly assigned", badCode === "£24"); +test("goodCode variable correctly assigned", goodCode === "£24"); From 3f690b8afe64203c98eb6373eefe3e55b435905d Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 1 May 2020 18:41:35 +0100 Subject: [PATCH 03/37] Changed 2-piping exercise --- week-1/Homework/extra/2-piping.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/week-1/Homework/extra/2-piping.js b/week-1/Homework/extra/2-piping.js index b00ce9565..56a238c63 100644 --- a/week-1/Homework/extra/2-piping.js +++ b/week-1/Homework/extra/2-piping.js @@ -28,14 +28,19 @@ function multiply(b, c) { function format(d) { return "£" + d; } - +console.log(add(1, 3)); +console.log(add(2.4, 5.3)); const startingValue = 2; -addValue = add(startingValue, 10); -multiplayValue = multiply(addValue, 2); + // Why can this code be seen as bad practice? Comment your answer. -let badCode = format(multiplayValue); + +let badCode = format(multiply(add(10, startingValue), 2)); + /* BETTER PRACTICE */ +addValue = add(startingValue, 10); +multiplayValue = multiply(addValue, 2); + let goodCode = format(multiplayValue); /* ======= TESTS - DO NOT MODIFY ===== */ From 380324367b0236752c80b6ae3a6530e41a04c83b Mon Sep 17 00:00:00 2001 From: Aronja Date: Sat, 2 May 2020 07:53:43 +0100 Subject: [PATCH 04/37] Use last year's exercises for scotland class 4 --- week-2/{Homework => .archive}/README.md | 0 week-2/{Homework => .archive}/extra/4-radio-stations.js | 0 week-2/{Homework => .archive}/mandatory/0-freecodecamp.md | 0 week-2/{Homework => .archive}/mandatory/1-fix-functions.js | 0 week-2/{Homework => .archive}/mandatory/2-function-creation.js | 0 week-2/{Homework => .archive}/mandatory/3-playing-computer.js | 0 week-2/{Homework => .archive}/mandatory/4-sorting-algorithm.js | 0 week-2/{.archive => Homework}/A-expressions/README.md | 0 week-2/{.archive => Homework}/B-boolean-literals/README.md | 0 week-2/{.archive => Homework}/B-boolean-literals/exercise.js | 0 week-2/{.archive => Homework}/C-comparison-operators/README.md | 0 week-2/{.archive => Homework}/C-comparison-operators/exercise.js | 0 week-2/{.archive => Homework}/D-predicates/README.md | 0 week-2/{.archive => Homework}/D-predicates/exercise.js | 0 week-2/{.archive => Homework}/E-conditionals/README.md | 0 week-2/{.archive => Homework}/E-conditionals/exercise.js | 0 week-2/{.archive => Homework}/F-logical-operators/README.md | 0 week-2/{.archive => Homework}/F-logical-operators/exercise.js | 0 week-2/{.archive => Homework}/F-logical-operators/exercise2.js | 0 week-2/{.archive => Homework}/G-conditionals-2/README.md | 0 week-2/{.archive => Homework}/G-conditionals-2/exercise-1.js | 0 week-2/{.archive => Homework}/G-conditionals-2/exercise-2.js | 0 week-2/{.archive => Homework}/G-conditionals-2/exercise-3.js | 0 week-2/{.archive => Homework}/G-conditionals-2/exercise-4.js | 0 week-2/{.archive => Homework}/H-array-literals/README.md | 0 week-2/{.archive => Homework}/H-array-literals/exercise.js | 0 week-2/{.archive => Homework}/I-array-properties/README.md | 0 week-2/{.archive => Homework}/I-array-properties/exercise.js | 0 week-2/{.archive => Homework}/J-array-get-set/README.md | 0 week-2/{.archive => Homework}/J-array-get-set/exercise.js | 0 week-2/{.archive => Homework}/J-array-get-set/exercises2.js | 0 week-2/{.archive => Homework}/K-array-methods/README.md | 0 week-2/{.archive => Homework}/K-array-methods/exercise.js | 0 week-2/{.archive => Homework}/K-array-methods/exercise2.js | 0 week-2/{.archive => Homework}/L-array-methods-2/README.md | 0 week-2/{.archive => Homework}/L-array-methods-2/exercise.js | 0 week-2/{.archive => Homework}/L-array-methods-2/exercise2.js | 0 week-2/{.archive => Homework}/L-array-methods-2/exercise3.js | 0 week-2/{.archive => Homework}/M-array-map/README.md | 0 week-2/{.archive => Homework}/M-array-map/exercise.js | 0 40 files changed, 0 insertions(+), 0 deletions(-) rename week-2/{Homework => .archive}/README.md (100%) rename week-2/{Homework => .archive}/extra/4-radio-stations.js (100%) rename week-2/{Homework => .archive}/mandatory/0-freecodecamp.md (100%) rename week-2/{Homework => .archive}/mandatory/1-fix-functions.js (100%) rename week-2/{Homework => .archive}/mandatory/2-function-creation.js (100%) rename week-2/{Homework => .archive}/mandatory/3-playing-computer.js (100%) rename week-2/{Homework => .archive}/mandatory/4-sorting-algorithm.js (100%) rename week-2/{.archive => Homework}/A-expressions/README.md (100%) rename week-2/{.archive => Homework}/B-boolean-literals/README.md (100%) rename week-2/{.archive => Homework}/B-boolean-literals/exercise.js (100%) rename week-2/{.archive => Homework}/C-comparison-operators/README.md (100%) rename week-2/{.archive => Homework}/C-comparison-operators/exercise.js (100%) rename week-2/{.archive => Homework}/D-predicates/README.md (100%) rename week-2/{.archive => Homework}/D-predicates/exercise.js (100%) rename week-2/{.archive => Homework}/E-conditionals/README.md (100%) rename week-2/{.archive => Homework}/E-conditionals/exercise.js (100%) rename week-2/{.archive => Homework}/F-logical-operators/README.md (100%) rename week-2/{.archive => Homework}/F-logical-operators/exercise.js (100%) rename week-2/{.archive => Homework}/F-logical-operators/exercise2.js (100%) rename week-2/{.archive => Homework}/G-conditionals-2/README.md (100%) rename week-2/{.archive => Homework}/G-conditionals-2/exercise-1.js (100%) rename week-2/{.archive => Homework}/G-conditionals-2/exercise-2.js (100%) rename week-2/{.archive => Homework}/G-conditionals-2/exercise-3.js (100%) rename week-2/{.archive => Homework}/G-conditionals-2/exercise-4.js (100%) rename week-2/{.archive => Homework}/H-array-literals/README.md (100%) rename week-2/{.archive => Homework}/H-array-literals/exercise.js (100%) rename week-2/{.archive => Homework}/I-array-properties/README.md (100%) rename week-2/{.archive => Homework}/I-array-properties/exercise.js (100%) rename week-2/{.archive => Homework}/J-array-get-set/README.md (100%) rename week-2/{.archive => Homework}/J-array-get-set/exercise.js (100%) rename week-2/{.archive => Homework}/J-array-get-set/exercises2.js (100%) rename week-2/{.archive => Homework}/K-array-methods/README.md (100%) rename week-2/{.archive => Homework}/K-array-methods/exercise.js (100%) rename week-2/{.archive => Homework}/K-array-methods/exercise2.js (100%) rename week-2/{.archive => Homework}/L-array-methods-2/README.md (100%) rename week-2/{.archive => Homework}/L-array-methods-2/exercise.js (100%) rename week-2/{.archive => Homework}/L-array-methods-2/exercise2.js (100%) rename week-2/{.archive => Homework}/L-array-methods-2/exercise3.js (100%) rename week-2/{.archive => Homework}/M-array-map/README.md (100%) rename week-2/{.archive => Homework}/M-array-map/exercise.js (100%) diff --git a/week-2/Homework/README.md b/week-2/.archive/README.md similarity index 100% rename from week-2/Homework/README.md rename to week-2/.archive/README.md diff --git a/week-2/Homework/extra/4-radio-stations.js b/week-2/.archive/extra/4-radio-stations.js similarity index 100% rename from week-2/Homework/extra/4-radio-stations.js rename to week-2/.archive/extra/4-radio-stations.js diff --git a/week-2/Homework/mandatory/0-freecodecamp.md b/week-2/.archive/mandatory/0-freecodecamp.md similarity index 100% rename from week-2/Homework/mandatory/0-freecodecamp.md rename to week-2/.archive/mandatory/0-freecodecamp.md diff --git a/week-2/Homework/mandatory/1-fix-functions.js b/week-2/.archive/mandatory/1-fix-functions.js similarity index 100% rename from week-2/Homework/mandatory/1-fix-functions.js rename to week-2/.archive/mandatory/1-fix-functions.js diff --git a/week-2/Homework/mandatory/2-function-creation.js b/week-2/.archive/mandatory/2-function-creation.js similarity index 100% rename from week-2/Homework/mandatory/2-function-creation.js rename to week-2/.archive/mandatory/2-function-creation.js diff --git a/week-2/Homework/mandatory/3-playing-computer.js b/week-2/.archive/mandatory/3-playing-computer.js similarity index 100% rename from week-2/Homework/mandatory/3-playing-computer.js rename to week-2/.archive/mandatory/3-playing-computer.js diff --git a/week-2/Homework/mandatory/4-sorting-algorithm.js b/week-2/.archive/mandatory/4-sorting-algorithm.js similarity index 100% rename from week-2/Homework/mandatory/4-sorting-algorithm.js rename to week-2/.archive/mandatory/4-sorting-algorithm.js diff --git a/week-2/.archive/A-expressions/README.md b/week-2/Homework/A-expressions/README.md similarity index 100% rename from week-2/.archive/A-expressions/README.md rename to week-2/Homework/A-expressions/README.md diff --git a/week-2/.archive/B-boolean-literals/README.md b/week-2/Homework/B-boolean-literals/README.md similarity index 100% rename from week-2/.archive/B-boolean-literals/README.md rename to week-2/Homework/B-boolean-literals/README.md diff --git a/week-2/.archive/B-boolean-literals/exercise.js b/week-2/Homework/B-boolean-literals/exercise.js similarity index 100% rename from week-2/.archive/B-boolean-literals/exercise.js rename to week-2/Homework/B-boolean-literals/exercise.js diff --git a/week-2/.archive/C-comparison-operators/README.md b/week-2/Homework/C-comparison-operators/README.md similarity index 100% rename from week-2/.archive/C-comparison-operators/README.md rename to week-2/Homework/C-comparison-operators/README.md diff --git a/week-2/.archive/C-comparison-operators/exercise.js b/week-2/Homework/C-comparison-operators/exercise.js similarity index 100% rename from week-2/.archive/C-comparison-operators/exercise.js rename to week-2/Homework/C-comparison-operators/exercise.js diff --git a/week-2/.archive/D-predicates/README.md b/week-2/Homework/D-predicates/README.md similarity index 100% rename from week-2/.archive/D-predicates/README.md rename to week-2/Homework/D-predicates/README.md diff --git a/week-2/.archive/D-predicates/exercise.js b/week-2/Homework/D-predicates/exercise.js similarity index 100% rename from week-2/.archive/D-predicates/exercise.js rename to week-2/Homework/D-predicates/exercise.js diff --git a/week-2/.archive/E-conditionals/README.md b/week-2/Homework/E-conditionals/README.md similarity index 100% rename from week-2/.archive/E-conditionals/README.md rename to week-2/Homework/E-conditionals/README.md diff --git a/week-2/.archive/E-conditionals/exercise.js b/week-2/Homework/E-conditionals/exercise.js similarity index 100% rename from week-2/.archive/E-conditionals/exercise.js rename to week-2/Homework/E-conditionals/exercise.js diff --git a/week-2/.archive/F-logical-operators/README.md b/week-2/Homework/F-logical-operators/README.md similarity index 100% rename from week-2/.archive/F-logical-operators/README.md rename to week-2/Homework/F-logical-operators/README.md diff --git a/week-2/.archive/F-logical-operators/exercise.js b/week-2/Homework/F-logical-operators/exercise.js similarity index 100% rename from week-2/.archive/F-logical-operators/exercise.js rename to week-2/Homework/F-logical-operators/exercise.js diff --git a/week-2/.archive/F-logical-operators/exercise2.js b/week-2/Homework/F-logical-operators/exercise2.js similarity index 100% rename from week-2/.archive/F-logical-operators/exercise2.js rename to week-2/Homework/F-logical-operators/exercise2.js diff --git a/week-2/.archive/G-conditionals-2/README.md b/week-2/Homework/G-conditionals-2/README.md similarity index 100% rename from week-2/.archive/G-conditionals-2/README.md rename to week-2/Homework/G-conditionals-2/README.md diff --git a/week-2/.archive/G-conditionals-2/exercise-1.js b/week-2/Homework/G-conditionals-2/exercise-1.js similarity index 100% rename from week-2/.archive/G-conditionals-2/exercise-1.js rename to week-2/Homework/G-conditionals-2/exercise-1.js diff --git a/week-2/.archive/G-conditionals-2/exercise-2.js b/week-2/Homework/G-conditionals-2/exercise-2.js similarity index 100% rename from week-2/.archive/G-conditionals-2/exercise-2.js rename to week-2/Homework/G-conditionals-2/exercise-2.js diff --git a/week-2/.archive/G-conditionals-2/exercise-3.js b/week-2/Homework/G-conditionals-2/exercise-3.js similarity index 100% rename from week-2/.archive/G-conditionals-2/exercise-3.js rename to week-2/Homework/G-conditionals-2/exercise-3.js diff --git a/week-2/.archive/G-conditionals-2/exercise-4.js b/week-2/Homework/G-conditionals-2/exercise-4.js similarity index 100% rename from week-2/.archive/G-conditionals-2/exercise-4.js rename to week-2/Homework/G-conditionals-2/exercise-4.js diff --git a/week-2/.archive/H-array-literals/README.md b/week-2/Homework/H-array-literals/README.md similarity index 100% rename from week-2/.archive/H-array-literals/README.md rename to week-2/Homework/H-array-literals/README.md diff --git a/week-2/.archive/H-array-literals/exercise.js b/week-2/Homework/H-array-literals/exercise.js similarity index 100% rename from week-2/.archive/H-array-literals/exercise.js rename to week-2/Homework/H-array-literals/exercise.js diff --git a/week-2/.archive/I-array-properties/README.md b/week-2/Homework/I-array-properties/README.md similarity index 100% rename from week-2/.archive/I-array-properties/README.md rename to week-2/Homework/I-array-properties/README.md diff --git a/week-2/.archive/I-array-properties/exercise.js b/week-2/Homework/I-array-properties/exercise.js similarity index 100% rename from week-2/.archive/I-array-properties/exercise.js rename to week-2/Homework/I-array-properties/exercise.js diff --git a/week-2/.archive/J-array-get-set/README.md b/week-2/Homework/J-array-get-set/README.md similarity index 100% rename from week-2/.archive/J-array-get-set/README.md rename to week-2/Homework/J-array-get-set/README.md diff --git a/week-2/.archive/J-array-get-set/exercise.js b/week-2/Homework/J-array-get-set/exercise.js similarity index 100% rename from week-2/.archive/J-array-get-set/exercise.js rename to week-2/Homework/J-array-get-set/exercise.js diff --git a/week-2/.archive/J-array-get-set/exercises2.js b/week-2/Homework/J-array-get-set/exercises2.js similarity index 100% rename from week-2/.archive/J-array-get-set/exercises2.js rename to week-2/Homework/J-array-get-set/exercises2.js diff --git a/week-2/.archive/K-array-methods/README.md b/week-2/Homework/K-array-methods/README.md similarity index 100% rename from week-2/.archive/K-array-methods/README.md rename to week-2/Homework/K-array-methods/README.md diff --git a/week-2/.archive/K-array-methods/exercise.js b/week-2/Homework/K-array-methods/exercise.js similarity index 100% rename from week-2/.archive/K-array-methods/exercise.js rename to week-2/Homework/K-array-methods/exercise.js diff --git a/week-2/.archive/K-array-methods/exercise2.js b/week-2/Homework/K-array-methods/exercise2.js similarity index 100% rename from week-2/.archive/K-array-methods/exercise2.js rename to week-2/Homework/K-array-methods/exercise2.js diff --git a/week-2/.archive/L-array-methods-2/README.md b/week-2/Homework/L-array-methods-2/README.md similarity index 100% rename from week-2/.archive/L-array-methods-2/README.md rename to week-2/Homework/L-array-methods-2/README.md diff --git a/week-2/.archive/L-array-methods-2/exercise.js b/week-2/Homework/L-array-methods-2/exercise.js similarity index 100% rename from week-2/.archive/L-array-methods-2/exercise.js rename to week-2/Homework/L-array-methods-2/exercise.js diff --git a/week-2/.archive/L-array-methods-2/exercise2.js b/week-2/Homework/L-array-methods-2/exercise2.js similarity index 100% rename from week-2/.archive/L-array-methods-2/exercise2.js rename to week-2/Homework/L-array-methods-2/exercise2.js diff --git a/week-2/.archive/L-array-methods-2/exercise3.js b/week-2/Homework/L-array-methods-2/exercise3.js similarity index 100% rename from week-2/.archive/L-array-methods-2/exercise3.js rename to week-2/Homework/L-array-methods-2/exercise3.js diff --git a/week-2/.archive/M-array-map/README.md b/week-2/Homework/M-array-map/README.md similarity index 100% rename from week-2/.archive/M-array-map/README.md rename to week-2/Homework/M-array-map/README.md diff --git a/week-2/.archive/M-array-map/exercise.js b/week-2/Homework/M-array-map/exercise.js similarity index 100% rename from week-2/.archive/M-array-map/exercise.js rename to week-2/Homework/M-array-map/exercise.js From dd4a1b27a23a530d8349189506f1615435186007 Mon Sep 17 00:00:00 2001 From: Aronja Date: Sat, 2 May 2020 08:41:50 +0100 Subject: [PATCH 05/37] Add Loops exercises --- .DS_Store | Bin 6148 -> 6148 bytes week-2/Homework/H-loops/exercise-1.js | 21 +++++++ week-2/Homework/H-loops/exercise-2.js | 59 ++++++++++++++++++ .../README.md | 0 .../exercise.js | 0 .../README.md | 0 .../exercise.js | 0 7 files changed, 80 insertions(+) create mode 100644 week-2/Homework/H-loops/exercise-1.js create mode 100644 week-2/Homework/H-loops/exercise-2.js rename week-2/Homework/{H-array-literals => I-array-literals}/README.md (100%) rename week-2/Homework/{H-array-literals => I-array-literals}/exercise.js (100%) rename week-2/Homework/{I-array-properties => N-array-properties}/README.md (100%) rename week-2/Homework/{I-array-properties => N-array-properties}/exercise.js (100%) diff --git a/.DS_Store b/.DS_Store index 4cb80315b900b193fd795b5d9b2fdab012e15a6d..49ac4c4ed20c7fc85fbdabdcac374e9dad8b9abb 100644 GIT binary patch delta 39 vcmZoMXfc@J&&azmU^g=(?`9sBZA_DIvhYmiVON-(#XfgpL(OJ(j=%f>_#_P6 delta 145 zcmZoMXfc@J&&a Date: Sat, 2 May 2020 08:47:18 +0100 Subject: [PATCH 06/37] Add expected result to while loop exercise --- week-2/Homework/H-loops/exercise-1.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/week-2/Homework/H-loops/exercise-1.js b/week-2/Homework/H-loops/exercise-1.js index bdf81cbf1..97eb2435a 100644 --- a/week-2/Homework/H-loops/exercise-1.js +++ b/week-2/Homework/H-loops/exercise-1.js @@ -19,3 +19,16 @@ Exercise 1: const hungry = 6; // add your code here, start with: while(...) {...} + + + + /* + EXPECTED RESULT + --------------- + eating 1 slice of pizza + eating 1 slice of pizza + eating 1 slice of pizza + eating 1 slice of pizza + eating 1 slice of pizza + eating 1 slice of pizza + */ From 1b0585889c301cb1c8af6a30597f3b48a8c13893 Mon Sep 17 00:00:00 2001 From: Aronja Date: Sat, 2 May 2020 09:10:04 +0100 Subject: [PATCH 07/37] Remove array method exercises --- week-2/Homework/K-array-methods/README.md | 55 ------------------- week-2/Homework/K-array-methods/exercise.js | 19 ------- week-2/Homework/K-array-methods/exercise2.js | 22 -------- .../README.md | 0 .../exercise.js | 0 week-2/Homework/L-array-methods-2/README.md | 46 ---------------- week-2/Homework/L-array-methods-2/exercise.js | 33 ----------- .../Homework/L-array-methods-2/exercise2.js | 25 --------- .../Homework/L-array-methods-2/exercise3.js | 26 --------- week-2/Homework/M-array-map/README.md | 27 --------- week-2/Homework/M-array-map/exercise.js | 24 -------- 11 files changed, 277 deletions(-) delete mode 100644 week-2/Homework/K-array-methods/README.md delete mode 100644 week-2/Homework/K-array-methods/exercise.js delete mode 100644 week-2/Homework/K-array-methods/exercise2.js rename week-2/Homework/{N-array-properties => K-array-properties}/README.md (100%) rename week-2/Homework/{N-array-properties => K-array-properties}/exercise.js (100%) delete mode 100644 week-2/Homework/L-array-methods-2/README.md delete mode 100644 week-2/Homework/L-array-methods-2/exercise.js delete mode 100644 week-2/Homework/L-array-methods-2/exercise2.js delete mode 100644 week-2/Homework/L-array-methods-2/exercise3.js delete mode 100644 week-2/Homework/M-array-map/README.md delete mode 100644 week-2/Homework/M-array-map/exercise.js diff --git a/week-2/Homework/K-array-methods/README.md b/week-2/Homework/K-array-methods/README.md deleted file mode 100644 index cc568c23b..000000000 --- a/week-2/Homework/K-array-methods/README.md +++ /dev/null @@ -1,55 +0,0 @@ -Do you remember how strings have special functions called methods? Don't worry if not! Here's an example to jog your memory: - -```sh -$ node -> var name = "Daniel" -undefined -> name.toLowerCase() -daniel -``` - -Arrays also have several methods that you can use. - -### `.sort()` - -_An array method that sorts the values in an array into ascending alphabetical or numerical order._ - -```js -var unorderedLetters = ["z", "v", "b", "f", "g"]; -var orderedLetters = unorderedLetters.sort(); - -var unorderedNumbers = [8, 5, 1, 4, 2]; -var orderedNumbers = unorderedNumbers.sort(); - -console.log(orderedLetters); // logs [ 'b', 'f', 'g', 'v', 'z' ] -console.log(unorderedLetters); // logs [ 'b', 'f', 'g', 'v', 'z' ] -console.log(orderedNumbers); // logs [ 1, 2, 4, 5, 8 ] -console.log(unorderedNumbers); // logs [ 1, 2, 4, 5, 8 ] -``` - -> When you call this array method it uses the array on the left side of the dot as an input, and it sorts that array also returning it. Note how both ordered and unordered arrays are sorted now! - -### `.concat()` - -_Adds (or concatenates) another value or array to the array._ - -```sh -$ node -> var arr = [1, 2, 3] -undefined -> arr.concat(4) -[1, 2, 3, 4] -> arr -[1, 2, 3] -``` - -Did you notice how calling the concat method did not change `arr`? This is because `concat`, like most array methods, returns a _new_ array, it does not alter the one you called the method on. - -If you wan to use the array returned by calling `.concat()` you should store it in a new variable. - -```js -var arr = [1, 2, 3]; -var newArr = arr.concat(4); - -console.log(newArr); // logs [1, 2, 3, 4] -``` diff --git a/week-2/Homework/K-array-methods/exercise.js b/week-2/Homework/K-array-methods/exercise.js deleted file mode 100644 index 44e9c8012..000000000 --- a/week-2/Homework/K-array-methods/exercise.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - Array methods - sort - -------------------- -*/ - -var numbers = [3, 2, 1]; -var sortedNumbers; // complete this statement - -/* - DO NOT EDIT BELOW THIS LINE - --------------------------- */ - -console.log(sortedNumbers); - -/* - EXPECTED RESULT - --------------- - [1, 2, 3] -*/ diff --git a/week-2/Homework/K-array-methods/exercise2.js b/week-2/Homework/K-array-methods/exercise2.js deleted file mode 100644 index 3dd24a17a..000000000 --- a/week-2/Homework/K-array-methods/exercise2.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - Array methods - concat - ---------------------- - The variable everyone should be an array containing both mentors and students. -*/ - -var mentors = ["Daniel", "Irina", "Rares"]; -var students = ["Rukmini", "Abdul", "Austine", "Swathi"]; - -var everyone; // complete this statement - -/* - DO NOT EDIT BELOW THIS LINE - --------------------------- */ - -console.log(everyone); - -/* - EXPECTED RESULT - --------------- - ["Daniel", "Irina", "Rares", "Rukmini", "Abdul", "Austine", "Swathi"] -*/ diff --git a/week-2/Homework/N-array-properties/README.md b/week-2/Homework/K-array-properties/README.md similarity index 100% rename from week-2/Homework/N-array-properties/README.md rename to week-2/Homework/K-array-properties/README.md diff --git a/week-2/Homework/N-array-properties/exercise.js b/week-2/Homework/K-array-properties/exercise.js similarity index 100% rename from week-2/Homework/N-array-properties/exercise.js rename to week-2/Homework/K-array-properties/exercise.js diff --git a/week-2/Homework/L-array-methods-2/README.md b/week-2/Homework/L-array-methods-2/README.md deleted file mode 100644 index 507de3192..000000000 --- a/week-2/Homework/L-array-methods-2/README.md +++ /dev/null @@ -1,46 +0,0 @@ -Let's explore some more array methods. - -### `.slice()` - -_Returns a slice of the array._ - -You can tell `.slice()` where you want the slice to begin and end by passing it two parameters. - -```sh -$ node -> var arr = [0, 1, 2, 3, 4] -undefined -> arr.slice(0, 2) -[0, 1] -> ["a", "b", "c", "d"].slice(1, 2) -['b'] -``` - -### `.includes()` - -_Returns true if a value is in the array._ - -```js -var mentors = ["Daniel", "Irini", "Ashleigh", "Rob", "Etzali"]; - -function isAMentor(name) { - return mentors.includes(name); -} - -consooe.log("Is Rukmuni a mentor?"); -console.log(isAMentor("Rukmini")); // logs false -``` - -### `.join()` - -_Returns all the array values joined together in a string. By default, this method takes no parameters and then the elements are divided with a comma `,`. If you provide it with a string parameter though, then it becomes the divider of the elements, like the example below:_ - -```sh -$ node -> ["H", "e", "l", "l", "o"].join(); -'H,e,l,l,o' -> ["H", "e", "l", "l", "o"].join("--"); -'H--e--l--l--o' -``` - -There is a string method `.split()`. In an interactive console try using the string `.split()` method and the array `.join()`. How could they work together? diff --git a/week-2/Homework/L-array-methods-2/exercise.js b/week-2/Homework/L-array-methods-2/exercise.js deleted file mode 100644 index d36303b84..000000000 --- a/week-2/Homework/L-array-methods-2/exercise.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - Array methods - .slice() - ------------------------ - The variable `firstFive` should contain the first five items of `everyone` - The variable `lastFive` should contain the last five items of `everyone` -*/ - -var everyone = [ - "Daniel", - "Irina", - "Rares", - "Rukmini", - "Abdul", - "Austine", - "Swathi" -]; - -var firstFive; // complete this statement -var lastFive; // complete this statement - -/* - DO NOT EDIT BELOW THIS LINE - --------------------------- */ - -console.log(firstFive); -console.log(lastFive); - -/* - EXPECTED RESULT - --------------- - ["Daniel", "Irina", "Rares", "Rukmini", "Abdul"] - ["Rares", "Rukmini", "Abdul", "Austine", "Swathi"] -*/ diff --git a/week-2/Homework/L-array-methods-2/exercise2.js b/week-2/Homework/L-array-methods-2/exercise2.js deleted file mode 100644 index b7be576e7..000000000 --- a/week-2/Homework/L-array-methods-2/exercise2.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - Array methods - .join() - ------------------------- - Complete the capitalise function - It should return a string with the first letter in uppercase - For example, capitailise("hello") should return "Hello" - Tip: use the string method .split() and the array method .join() -*/ - -function capitalise(str) {} - -/* - DO NOT EDIT BELOW THIS LINE - --------------------------- */ -var name = "daniel"; - -console.log(capitalise(name)); -console.log(capitalise("hello")); - -/* - EXPECTED RESULT - --------------- - Daniel - Hello -*/ diff --git a/week-2/Homework/L-array-methods-2/exercise3.js b/week-2/Homework/L-array-methods-2/exercise3.js deleted file mode 100644 index 82e9dd8c8..000000000 --- a/week-2/Homework/L-array-methods-2/exercise3.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - Array methods - .includes() - --------------------------- - Complete the function below to check if a country is in the UK -*/ - -var ukNations = ["Scotland", "Wales", "England", "Northern Ireland"]; - -function isInUK(country) { - return; // complete this statement -} - -/* - DO NOT EDIT BELOW THIS LINE - --------------------------- */ -console.log(isInUK("France")); -console.log(isInUK("Republic of Ireland")); -console.log(isInUK("England")); - -/* - EXPECTED RESULT - --------------- - false - false - true -*/ diff --git a/week-2/Homework/M-array-map/README.md b/week-2/Homework/M-array-map/README.md deleted file mode 100644 index 76ef865e2..000000000 --- a/week-2/Homework/M-array-map/README.md +++ /dev/null @@ -1,27 +0,0 @@ -Imagine you have an array of names... - -```js -var mentors = ["Daniel ", "irina ", " Gordon", "ashleigh "]; -``` - -You notice that he names are not formatted consistently. To fix the array you decide you need to trim whitespace and convert to lowercase. How do you do that for every value in the array? - -We can write a function that changes one name: - -```js -function tidy(name) { - return name.trim().toLowerCase(); -} -``` - -All you need to run every name in the array through this function and update the array values. Thankfully there is an array method that does just this! - -## `.map()` - -_Runs every item in the array through a function and returns a new array with the values returned by the function_. - -```js -var tidyMentors = mentors.map(tidy); - -console.log(tidyMentors); // logs ["daniel", "irina", "gordon", "ashleigh"] -``` diff --git a/week-2/Homework/M-array-map/exercise.js b/week-2/Homework/M-array-map/exercise.js deleted file mode 100644 index 783e8386c..000000000 --- a/week-2/Homework/M-array-map/exercise.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - Array methods - .map() - ------------------------- - `numbersDoubled` should be an array containing all every value in `numbers` doubled - Use the .map() method to transform each item in the array -*/ - -function double(num) { - return num * 2; -} - -var numbers = [1, 2, 3, 4]; -var numbersDoubled; // complete this statement (use map and the double function) - -/* - DO NOT EDIT BELOW THIS LINE - --------------------------- */ -console.log(numbersDoubled); - -/* - EXPECTED RESULT - --------------- - [2,4,6,8] -*/ From faac018e9f6696fd04b3fa662f739b73ecb2e3c8 Mon Sep 17 00:00:00 2001 From: Aronja Date: Sat, 2 May 2020 13:19:28 +0100 Subject: [PATCH 08/37] Add more While loop exercises Co-authored-by: Richard --- week-2/Homework/H-loops/exercise-1.js | 30 +++++++++++++++++++++++++-- week-2/Homework/H-loops/exercise-2.js | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/week-2/Homework/H-loops/exercise-1.js b/week-2/Homework/H-loops/exercise-1.js index 97eb2435a..61b018c97 100644 --- a/week-2/Homework/H-loops/exercise-1.js +++ b/week-2/Homework/H-loops/exercise-1.js @@ -1,8 +1,34 @@ /* - While Loops + WHILE LOOPS --------------------------------- -Exercise 1: + Using while loops complete the exercises to output the correct results. +*/ +​ +// This while loop outputs "Hello" 10 times. Change the code so it only outputs "Hello" 5 times +let i = 0; +while(i < 10){ + console.log("Hello"); + i++; +} +​ +// This while loop doesn't do anything! Change the code so it outputs the sentence "Coding is easy" 3 times +i = 0; +while(i < 5){ +​ + i++; +} +​ +// This while loop uses the variable loopLimit in its condition. +// Change the code below so it outputs "Goodbye" 5 times +let loopLimit = 2; +i = 0; +while(i < loopLimit){ // don't change this line! + console.log("Goodbye"); + i++; +} + +/* Write a while loop that prints "eating 1 slice of pizza" 6 times to the console. Use the variables slices and hungry to create a condition. diff --git a/week-2/Homework/H-loops/exercise-2.js b/week-2/Homework/H-loops/exercise-2.js index 9649f8704..e7c00a59d 100644 --- a/week-2/Homework/H-loops/exercise-2.js +++ b/week-2/Homework/H-loops/exercise-2.js @@ -1,5 +1,5 @@ /* -For-Loops +FOR LOOPS --------------------------------- Exercise 2-a: --------------------------------- From da65354ac436ddb73cf17c83533854cd8e9dc8e0 Mon Sep 17 00:00:00 2001 From: Aronja Date: Sat, 2 May 2020 13:56:29 +0100 Subject: [PATCH 09/37] Revert "Add more While loop exercises" This reverts commit faac018e9f6696fd04b3fa662f739b73ecb2e3c8. --- week-2/Homework/H-loops/exercise-1.js | 30 ++------------------------- week-2/Homework/H-loops/exercise-2.js | 2 +- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/week-2/Homework/H-loops/exercise-1.js b/week-2/Homework/H-loops/exercise-1.js index 61b018c97..97eb2435a 100644 --- a/week-2/Homework/H-loops/exercise-1.js +++ b/week-2/Homework/H-loops/exercise-1.js @@ -1,34 +1,8 @@ /* - WHILE LOOPS + While Loops --------------------------------- - Using while loops complete the exercises to output the correct results. -*/ -​ -// This while loop outputs "Hello" 10 times. Change the code so it only outputs "Hello" 5 times -let i = 0; -while(i < 10){ - console.log("Hello"); - i++; -} -​ -// This while loop doesn't do anything! Change the code so it outputs the sentence "Coding is easy" 3 times -i = 0; -while(i < 5){ -​ - i++; -} -​ -// This while loop uses the variable loopLimit in its condition. -// Change the code below so it outputs "Goodbye" 5 times -let loopLimit = 2; -i = 0; -while(i < loopLimit){ // don't change this line! - console.log("Goodbye"); - i++; -} +Exercise 1: - -/* Write a while loop that prints "eating 1 slice of pizza" 6 times to the console. Use the variables slices and hungry to create a condition. diff --git a/week-2/Homework/H-loops/exercise-2.js b/week-2/Homework/H-loops/exercise-2.js index e7c00a59d..9649f8704 100644 --- a/week-2/Homework/H-loops/exercise-2.js +++ b/week-2/Homework/H-loops/exercise-2.js @@ -1,5 +1,5 @@ /* -FOR LOOPS +For-Loops --------------------------------- Exercise 2-a: --------------------------------- From 8e466c83138ce6dcb2526d253a34a9c67fba4711 Mon Sep 17 00:00:00 2001 From: Aronja Date: Sat, 2 May 2020 14:28:11 +0100 Subject: [PATCH 10/37] Working while exercises Co-authored-by: Richard --- week-2/Homework/H-loops/exercise-1.js | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/week-2/Homework/H-loops/exercise-1.js b/week-2/Homework/H-loops/exercise-1.js index 97eb2435a..613ec058c 100644 --- a/week-2/Homework/H-loops/exercise-1.js +++ b/week-2/Homework/H-loops/exercise-1.js @@ -1,8 +1,39 @@ /* While Loops --------------------------------- -Exercise 1: + Using while loops complete the exercises to output the + correct results. +*/ + +//The while loop outputs "Hello" 10 times. Change the code so it only outputs "Hello" 5 times + +let i = 0; +while(i < 10) { + console.log("Hello"); + i++ +} + +//This while loop doesn't do anything! Change the code so it outputs the sentence "Coding is easy" 3 times + +let j = 0; +while(j < 5) { + + j++ +} + +// This while loop uses the variable loopLimit in its condition. +// Change the code below so it outputs "Goodbye" 5 times + +let loopLimit = 2; +k = 0; +while(k < loopLimit) { //don't change this line + console.log("Goodbye"); + k++ +} + + +/* Write a while loop that prints "eating 1 slice of pizza" 6 times to the console. Use the variables slices and hungry to create a condition. From 412666e14fee04b4eaa509dc58b2f08d9a996f7e Mon Sep 17 00:00:00 2001 From: Aronja Date: Sun, 3 May 2020 10:53:12 +0100 Subject: [PATCH 11/37] homework --- file | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 file diff --git a/file b/file new file mode 100644 index 000000000..e69de29bb From 0ac118b54babec179be5fc7a71d7d54dd33e0ed0 Mon Sep 17 00:00:00 2001 From: Aronja Date: Sun, 3 May 2020 10:54:01 +0100 Subject: [PATCH 12/37] Revert "homework" This reverts commit 412666e14fee04b4eaa509dc58b2f08d9a996f7e. --- file | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 file diff --git a/file b/file deleted file mode 100644 index e69de29bb..000000000 From c4f12f2eb80c763e63146fdc988684da5dfed315 Mon Sep 17 00:00:00 2001 From: Chris Owen Date: Tue, 12 May 2020 18:04:34 +0100 Subject: [PATCH 13/37] Add Old Homework To Scotland Class 4 Branch (#852) --- week-2/Homework/L-extra/level-1/1-boolean.js | 16 + .../Homework/L-extra/level-1/2-validation.js | 17 + week-2/Homework/L-extra/level-1/3-sort.js | 13 + week-2/Homework/L-extra/level-1/4-slice.js | 16 + week-2/Homework/L-extra/level-1/5-indexOf.js | 14 + week-2/Homework/L-extra/level-1/6-map.js | 22 + week-2/Homework/L-extra/level-2/1-boolean.js | 17 + .../Homework/L-extra/level-2/2-validation.js | 27 + week-2/Homework/L-extra/level-2/3-sort.js | 14 + week-2/Homework/L-extra/level-2/4-slice.js | 28 + week-2/Homework/L-extra/level-2/5-indexOf.js | 28 + week-2/Homework/L-extra/level-2/6-map.js | 14 + week-2/Homework/L-extra/level-3/1-boolean.js | 18 + .../Homework/L-extra/level-3/2-validation.js | 25 + week-2/Homework/L-extra/level-3/3-sort.js | 17 + week-2/Homework/L-extra/level-3/4-slice.js | 32 + week-2/Homework/L-extra/level-3/5-indexOf.js | 33 ++ week-2/Homework/L-extra/level-3/6-map.js | 26 + .../extra/1-card-vailidator.md | 0 .../mandatory/0-freecodecamp.md | 0 .../mandatory/1-oxygen-levels.js | 0 .../mandatory/2-bush-berries.js | 0 .../mandatory/3-space-colonies.js | 0 .../mandatory/4-eligible-students.js | 0 .../mandatory/5-journey-planner.js | 0 .../mandatory/6-lane-names.js | 0 .../mandatory/7-password-validator.js | 0 .../mandatory/8-codewars.md | 64 +- .../A-array-find/README.md | 0 .../A-array-find/exercise.js | 0 .../B-array-some/README.md | 0 .../B-array-some/exercise.js | 0 .../C-array-every/README.md | 0 .../C-array-every/exercise.js | 0 .../D-array-filter/README.md | 0 .../D-array-filter/exercise.js | 0 .../E-array-map/README.md | 0 .../E-array-map/exercise.js | 0 .../F-array-forEach/README.md | 0 .../F-array-forEach/exercise.js | 0 week-3/Homework/G-extra/1-map.js | 21 + week-3/Homework/G-extra/2-map.js | 24 + week-3/Homework/G-extra/3-filter.js | 560 ++++++++++++++++++ 43 files changed, 1014 insertions(+), 32 deletions(-) create mode 100644 week-2/Homework/L-extra/level-1/1-boolean.js create mode 100644 week-2/Homework/L-extra/level-1/2-validation.js create mode 100644 week-2/Homework/L-extra/level-1/3-sort.js create mode 100644 week-2/Homework/L-extra/level-1/4-slice.js create mode 100644 week-2/Homework/L-extra/level-1/5-indexOf.js create mode 100644 week-2/Homework/L-extra/level-1/6-map.js create mode 100644 week-2/Homework/L-extra/level-2/1-boolean.js create mode 100644 week-2/Homework/L-extra/level-2/2-validation.js create mode 100644 week-2/Homework/L-extra/level-2/3-sort.js create mode 100644 week-2/Homework/L-extra/level-2/4-slice.js create mode 100644 week-2/Homework/L-extra/level-2/5-indexOf.js create mode 100644 week-2/Homework/L-extra/level-2/6-map.js create mode 100644 week-2/Homework/L-extra/level-3/1-boolean.js create mode 100644 week-2/Homework/L-extra/level-3/2-validation.js create mode 100644 week-2/Homework/L-extra/level-3/3-sort.js create mode 100644 week-2/Homework/L-extra/level-3/4-slice.js create mode 100644 week-2/Homework/L-extra/level-3/5-indexOf.js create mode 100644 week-2/Homework/L-extra/level-3/6-map.js rename week-3/{Homework => .archive}/extra/1-card-vailidator.md (100%) rename week-3/{Homework => .archive}/mandatory/0-freecodecamp.md (100%) rename week-3/{Homework => .archive}/mandatory/1-oxygen-levels.js (100%) rename week-3/{Homework => .archive}/mandatory/2-bush-berries.js (100%) rename week-3/{Homework => .archive}/mandatory/3-space-colonies.js (100%) rename week-3/{Homework => .archive}/mandatory/4-eligible-students.js (100%) rename week-3/{Homework => .archive}/mandatory/5-journey-planner.js (100%) rename week-3/{Homework => .archive}/mandatory/6-lane-names.js (100%) rename week-3/{Homework => .archive}/mandatory/7-password-validator.js (100%) rename week-3/{Homework => .archive}/mandatory/8-codewars.md (98%) rename week-3/{.archive => Homework}/A-array-find/README.md (100%) rename week-3/{.archive => Homework}/A-array-find/exercise.js (100%) rename week-3/{.archive => Homework}/B-array-some/README.md (100%) rename week-3/{.archive => Homework}/B-array-some/exercise.js (100%) rename week-3/{.archive => Homework}/C-array-every/README.md (100%) rename week-3/{.archive => Homework}/C-array-every/exercise.js (100%) rename week-3/{.archive => Homework}/D-array-filter/README.md (100%) rename week-3/{.archive => Homework}/D-array-filter/exercise.js (100%) rename week-3/{.archive => Homework}/E-array-map/README.md (100%) rename week-3/{.archive => Homework}/E-array-map/exercise.js (100%) rename week-3/{.archive => Homework}/F-array-forEach/README.md (100%) rename week-3/{.archive => Homework}/F-array-forEach/exercise.js (100%) create mode 100644 week-3/Homework/G-extra/1-map.js create mode 100644 week-3/Homework/G-extra/2-map.js create mode 100644 week-3/Homework/G-extra/3-filter.js diff --git a/week-2/Homework/L-extra/level-1/1-boolean.js b/week-2/Homework/L-extra/level-1/1-boolean.js new file mode 100644 index 000000000..8c4290152 --- /dev/null +++ b/week-2/Homework/L-extra/level-1/1-boolean.js @@ -0,0 +1,16 @@ +// The code is valid but the program does not produce the expected result +// Fix it. + +var isHappy = false; + +if (isHappy) { + console.log("I am happy"); +} else { + console.log("I am not happy"); +} + +/* + EXPECTED RESULT + --------------- + I am happy +*/ diff --git a/week-2/Homework/L-extra/level-1/2-validation.js b/week-2/Homework/L-extra/level-1/2-validation.js new file mode 100644 index 000000000..4c34981e0 --- /dev/null +++ b/week-2/Homework/L-extra/level-1/2-validation.js @@ -0,0 +1,17 @@ +// Update the variable `isBigEnough` so that the program produces the expected result +// TIP: You should write an expression that returns a boolean value + +var num = 10; +var isBigEnough; // ONLY EDIT THIS LINE + +if (isBigEnough) { + console.log("num is bigger than or equal to 10"); +} else { + console.log("num is not big enough"); +} + +/* + EXPECTED RESULT + --------------- + num is bigger than or equal to 10 +*/ diff --git a/week-2/Homework/L-extra/level-1/3-sort.js b/week-2/Homework/L-extra/level-1/3-sort.js new file mode 100644 index 000000000..136bc8cb9 --- /dev/null +++ b/week-2/Homework/L-extra/level-1/3-sort.js @@ -0,0 +1,13 @@ +// Update the variable `sortedLetters` so that it contains the values of `letters` in ascending order +// TIP: use an array method + +var letters = ["a", "n", "c", "e", "z", "f"]; +var sortedLetters; // ONLY EDIT THIS LINE + +console.log(sortedLetters); + +/* + EXPECTED RESULT + --------------- + [ 'a', 'c', 'e', 'f', 'n', 'z' ] +*/ diff --git a/week-2/Homework/L-extra/level-1/4-slice.js b/week-2/Homework/L-extra/level-1/4-slice.js new file mode 100644 index 000000000..6183df636 --- /dev/null +++ b/week-2/Homework/L-extra/level-1/4-slice.js @@ -0,0 +1,16 @@ +// Write a function `first5` that: +// - returns the first 5 items from a provided array + +/* + DO NOT EDIT BELOW THIS LINE + --------------------------- */ +var numbers = [1, 2, 3, 4, 5, 6, 7, 8]; +var first5Numbers = first5(numbers); + +console.log(first5Numbers); + +/* + EXPECTED RESULT + --------------- + [1, 2, 3, 4, 5] +*/ diff --git a/week-2/Homework/L-extra/level-1/5-indexOf.js b/week-2/Homework/L-extra/level-1/5-indexOf.js new file mode 100644 index 000000000..bb99819a5 --- /dev/null +++ b/week-2/Homework/L-extra/level-1/5-indexOf.js @@ -0,0 +1,14 @@ +// Find the index of an item in an array +// TIP: use the .indexOf() method (search the web for documentation if you're not sure) + +var itemToFind = 7; +var arr = [3, 5, 61, 7, 123]; +var index; // ONLY EDIT THIS LINE + +console.log(index); + +/* + EXPECTED RESULT + --------------- + 3 +*/ diff --git a/week-2/Homework/L-extra/level-1/6-map.js b/week-2/Homework/L-extra/level-1/6-map.js new file mode 100644 index 000000000..520311c53 --- /dev/null +++ b/week-2/Homework/L-extra/level-1/6-map.js @@ -0,0 +1,22 @@ +// An array of mentor names has been provided to you, as well as a function to tidy up strings. +// Declare a new array (`mentorsTidy`) containing: +// - every item from `mentors` run through the `tidyUpString` function +// TIP: Use the .map() method + +function tidyUpString(str) { + return str + .trim() + .toLowerCase() + .replace("/", ""); +} + +var mentors = ["/Daniel ", "irina ", " Gordon", "ashleigh "]; +var mentorsTidy; // ONLY EDIT THIS LINE + +console.log(mentorsTidy); + +/* + EXPECTED RESULT + --------------- + ["daniel", "irina", "gordon", "ashleigh"] +*/ diff --git a/week-2/Homework/L-extra/level-2/1-boolean.js b/week-2/Homework/L-extra/level-2/1-boolean.js new file mode 100644 index 000000000..b1aa23a01 --- /dev/null +++ b/week-2/Homework/L-extra/level-2/1-boolean.js @@ -0,0 +1,17 @@ +// The code is valid but the program does not produce the expected result +// Why doesn't it work? +// Fix it. + +var isHappy = "false"; + +if (isHappy) { + console.log("I am happy"); +} else { + console.log("I am not happy"); +} + +/* + EXPECTED RESULT + --------------- + I am not happy +*/ diff --git a/week-2/Homework/L-extra/level-2/2-validation.js b/week-2/Homework/L-extra/level-2/2-validation.js new file mode 100644 index 000000000..2e76d6674 --- /dev/null +++ b/week-2/Homework/L-extra/level-2/2-validation.js @@ -0,0 +1,27 @@ +// Complete the function to check if the variable `num` satisfies the following requirements: +// - is a number +// - is a positive number +// - is less than or equal to 100 +// Tip: write other small functions for each requirement + +function validate(num) {} + +/* + DO NOT EDIT BELOW THIS LINE + --------------------------- */ + +console.log(validate(10)); +console.log(validate(10.5)); +console.log(validate(101)); +console.log(validate(-12)); +console.log(validate("16")); + +/* + EXPECTED RESULT + --------------- + true + true + false + false + false +*/ diff --git a/week-2/Homework/L-extra/level-2/3-sort.js b/week-2/Homework/L-extra/level-2/3-sort.js new file mode 100644 index 000000000..d288f6ab4 --- /dev/null +++ b/week-2/Homework/L-extra/level-2/3-sort.js @@ -0,0 +1,14 @@ +// Update the variable `sortedLetters`. +// It should contain the values of `letters` and `letters2` in ascending order + +var letters = ["a", "n", "c", "e", "z", "f"]; +var letters2 = ["w", "b", "v", "g", "l", "o"]; +var sortedLetters; // ONLY EDIT THIS LINE + +console.log(sortedLetters); + +/* + EXPECTED RESULT + --------------- + [ 'a', 'b', 'c', 'e', 'f', 'g', 'l','n', 'o', 'v', 'w', 'z' ] +*/ diff --git a/week-2/Homework/L-extra/level-2/4-slice.js b/week-2/Homework/L-extra/level-2/4-slice.js new file mode 100644 index 000000000..c02726e61 --- /dev/null +++ b/week-2/Homework/L-extra/level-2/4-slice.js @@ -0,0 +1,28 @@ +// Write a function that removes an element from an array +// The function must: +// - NOT change the original array +// - return a new array with the item removed +// - remove the item at the specified index + +function remove(arr, index) { + return; // complete this statement +} + +/* + DO NOT EDIT BELOW THIS LINE + --------------------------- */ +var numbers = [1, 2, 3]; +var names = ["Irina", "Ashleigh", "Mozafar"]; + +var newNumbers = remove(numbers, 2); +var newNames = remove(names, 1); + +console.log(newNumbers); +console.log(newNames); + +/* + EXPECTED RESULT + --------------- + [1, 2] + [Irina, Mozafar] +*/ diff --git a/week-2/Homework/L-extra/level-2/5-indexOf.js b/week-2/Homework/L-extra/level-2/5-indexOf.js new file mode 100644 index 000000000..204440b11 --- /dev/null +++ b/week-2/Homework/L-extra/level-2/5-indexOf.js @@ -0,0 +1,28 @@ +// Write a function that removes an element from an array +// The function must: +// - NOT change the original array +// - return a new array with the first item matching `valueToRemove` removed +// TIP: Use the .indexOf() method + +function remove(arr, valueToRemove) { + return; // complete this statement +} + +/* + DO NOT EDIT BELOW THIS LINE + --------------------------- */ +var numbers = [1, 2, 3]; +var names = ["Irina", "Ashleigh", "Mozafar"]; + +var newNumbers = remove(numbers, 2); +var newNames = remove(names, "Ashleigh"); + +console.log(newNumbers); +console.log(newNames); + +/* + EXPECTED RESULT + --------------- + [1, 3] + [Irina, Mozafar] +*/ diff --git a/week-2/Homework/L-extra/level-2/6-map.js b/week-2/Homework/L-extra/level-2/6-map.js new file mode 100644 index 000000000..0e2e10ab1 --- /dev/null +++ b/week-2/Homework/L-extra/level-2/6-map.js @@ -0,0 +1,14 @@ +// You have been given an array of percetages +// 1. Write a function that formats the numbers into a string with the percentage symbol appended e.g. "10%" +// 2. Declare a new array, `percentagesFormatted`, containing +// - each item in `percentages` formatted by your function + +var percentages = [1, 23, 92, 18]; + +console.log(percentagesFormatted); + +/* + EXPECTED RESULT + --------------- + [1%, 23%, 92%, 18%] +*/ diff --git a/week-2/Homework/L-extra/level-3/1-boolean.js b/week-2/Homework/L-extra/level-3/1-boolean.js new file mode 100644 index 000000000..4f2c44e39 --- /dev/null +++ b/week-2/Homework/L-extra/level-3/1-boolean.js @@ -0,0 +1,18 @@ +// The code is valid but is misleading and could be improved +// Refactor the code to make it better +// What was wrong with the original code? +// Leave comments above your changes to explain + +var isHappy = "false"; + +if (isHappy == true) { + console.log("I am happy"); +} else { + console.log("I am not happy"); +} + +/* + EXPECTED RESULT + --------------- + I am not happy +*/ diff --git a/week-2/Homework/L-extra/level-3/2-validation.js b/week-2/Homework/L-extra/level-3/2-validation.js new file mode 100644 index 000000000..d12a8cf0d --- /dev/null +++ b/week-2/Homework/L-extra/level-3/2-validation.js @@ -0,0 +1,25 @@ +// Complete the function to check if the variable `num` satisfies the following requirements: +// - is a number +// - is an integer (not a float) +// - is not equal any of the numbers in the array `excludedNums` +// Tip: write other small functions for each requirement + +var excludedNums = [6, 14, 91, 111]; + +function validate(num) {} + +console.log(validate(6)); +console.log(validate(10.5)); +console.log(validate(101)); +console.log(validate(-91)); +console.log(validate("16")); + +/* + EXPECTED RESULT + --------------- + false + false + true + true + false +*/ diff --git a/week-2/Homework/L-extra/level-3/3-sort.js b/week-2/Homework/L-extra/level-3/3-sort.js new file mode 100644 index 000000000..8d3dddae7 --- /dev/null +++ b/week-2/Homework/L-extra/level-3/3-sort.js @@ -0,0 +1,17 @@ +// 1. Update the variable `sortedNums`. +// It should contain the values of `nums` and `nums2` in ascending order +// Tip: you might need to read the documentation for .sort (search "mdn array sort") + +var nums = [10, 1, 5, 29, 100]; +var nums2 = [11, 6, 3, 29, 12]; +var sortedNums; // complete this statement + +console.log(sortedNums); + +// 2. Using code, show that the variables nums and nums2 were not changed + +/* + EXPECTED RESULT + --------------- + [ 1, 3, 5, 6, 10, 11, 12, 29, 29, 100 ] +*/ diff --git a/week-2/Homework/L-extra/level-3/4-slice.js b/week-2/Homework/L-extra/level-3/4-slice.js new file mode 100644 index 000000000..79911f127 --- /dev/null +++ b/week-2/Homework/L-extra/level-3/4-slice.js @@ -0,0 +1,32 @@ +// Write a function that replaces an element in an array +// The function must: +// - NOT change the original array +// - return a new array with the replacement value inserted +// - insert the replacement value at the provided index + +function replace(arr, index, value) { + return; // complete this statement +} + +/* + DO NOT EDIT BELOW THIS LINE + --------------------------- */ +var numbers = [1, 3, 3]; +var names = ["Irina", "Ashleigh", "Mozafar"]; + +var newNumbers = replace(numbers, 1, 2); +var newNames = replace(names, 2, "Rares"); + +console.log(numbers); +console.log(newNumbers); +console.log(names); +console.log(newNames); + +/* + EXPECTED RESULT + --------------- + [1, 3, 3] + [1, 2, 3] + [Irina, Ashleigh, Mozafar] + [Irina, Ashleigh, Rares] +*/ diff --git a/week-2/Homework/L-extra/level-3/5-indexOf.js b/week-2/Homework/L-extra/level-3/5-indexOf.js new file mode 100644 index 000000000..f24e500e4 --- /dev/null +++ b/week-2/Homework/L-extra/level-3/5-indexOf.js @@ -0,0 +1,33 @@ +// Write a function that replaces an element in an array +// The function must: +// - get the index of the first item matching `valueToReplace` +// - insert `newValue` at that index +// - NOT change the original array +// - return a new array with the replacement value inserted + +function replace(arr, valueToReplace, newValue) { + return; // complete this statement +} + +/* + DO NOT EDIT BELOW THIS LINE + --------------------------- */ +var numbers = [1, 3, 3]; +var names = ["Irina", "Ashleigh", "Mozafar"]; + +var newNumbers = replace(arr, 3, 2); +var newNames = replace(arr, "Ashleigh", "Rares"); + +console.log(numbers); +console.log(newNumbers); +console.log(names); +console.log(newNames); + +/* + EXPECTED RESULT + --------------- + [1, 3, 3] + [1, 2, 3] + [Irina, Ashleigh, Mozafar] + [Irina, Rares, Mozafar] +*/ diff --git a/week-2/Homework/L-extra/level-3/6-map.js b/week-2/Homework/L-extra/level-3/6-map.js new file mode 100644 index 000000000..42db906a2 --- /dev/null +++ b/week-2/Homework/L-extra/level-3/6-map.js @@ -0,0 +1,26 @@ +// 1. Write a function (`capitalise`) that capitalises the first letter of a provided string +// 2. Declare a new array (`mentorsTidy`) containing: +// - every item from `mentors` run through the `tidyUpString` function +// - every resulting item run through the `capitalise` function + +function tidyUpString(str) { + return str + .trim() + .toLowerCase() + .replace("/", ""); +} + +function capitalise(str) { + // complete this function +} + +var mentors = ["/Daniel ", "irina ", " Gordon", "ashleigh "]; +var mentorsTidyAndCapitalised; + +console.log(mentorsTidyAndCapitalised); + +/* + EXPECTED RESULT + --------------- + ["Daniel", "Irina", "Gordon", "Ashleigh"] +*/ diff --git a/week-3/Homework/extra/1-card-vailidator.md b/week-3/.archive/extra/1-card-vailidator.md similarity index 100% rename from week-3/Homework/extra/1-card-vailidator.md rename to week-3/.archive/extra/1-card-vailidator.md diff --git a/week-3/Homework/mandatory/0-freecodecamp.md b/week-3/.archive/mandatory/0-freecodecamp.md similarity index 100% rename from week-3/Homework/mandatory/0-freecodecamp.md rename to week-3/.archive/mandatory/0-freecodecamp.md diff --git a/week-3/Homework/mandatory/1-oxygen-levels.js b/week-3/.archive/mandatory/1-oxygen-levels.js similarity index 100% rename from week-3/Homework/mandatory/1-oxygen-levels.js rename to week-3/.archive/mandatory/1-oxygen-levels.js diff --git a/week-3/Homework/mandatory/2-bush-berries.js b/week-3/.archive/mandatory/2-bush-berries.js similarity index 100% rename from week-3/Homework/mandatory/2-bush-berries.js rename to week-3/.archive/mandatory/2-bush-berries.js diff --git a/week-3/Homework/mandatory/3-space-colonies.js b/week-3/.archive/mandatory/3-space-colonies.js similarity index 100% rename from week-3/Homework/mandatory/3-space-colonies.js rename to week-3/.archive/mandatory/3-space-colonies.js diff --git a/week-3/Homework/mandatory/4-eligible-students.js b/week-3/.archive/mandatory/4-eligible-students.js similarity index 100% rename from week-3/Homework/mandatory/4-eligible-students.js rename to week-3/.archive/mandatory/4-eligible-students.js diff --git a/week-3/Homework/mandatory/5-journey-planner.js b/week-3/.archive/mandatory/5-journey-planner.js similarity index 100% rename from week-3/Homework/mandatory/5-journey-planner.js rename to week-3/.archive/mandatory/5-journey-planner.js diff --git a/week-3/Homework/mandatory/6-lane-names.js b/week-3/.archive/mandatory/6-lane-names.js similarity index 100% rename from week-3/Homework/mandatory/6-lane-names.js rename to week-3/.archive/mandatory/6-lane-names.js diff --git a/week-3/Homework/mandatory/7-password-validator.js b/week-3/.archive/mandatory/7-password-validator.js similarity index 100% rename from week-3/Homework/mandatory/7-password-validator.js rename to week-3/.archive/mandatory/7-password-validator.js diff --git a/week-3/Homework/mandatory/8-codewars.md b/week-3/.archive/mandatory/8-codewars.md similarity index 98% rename from week-3/Homework/mandatory/8-codewars.md rename to week-3/.archive/mandatory/8-codewars.md index b9cab92f1..8bd2b85c5 100644 --- a/week-3/Homework/mandatory/8-codewars.md +++ b/week-3/.archive/mandatory/8-codewars.md @@ -1,33 +1,33 @@ -# Codewars Exercises - -Today, you'll be using a platform called [CodeWars](https://codewars.com) to help you recap the materials you learnt in JS1. CodeWars is an excellent platform for going through interesting JavaScript exercises, and allows you to communicate with the wider community to learn about the best way of writing JavaScript code. - -1. Make sure you finish all the pending exercies in week-1, week-2 and week-3 of the [js-exercises repo](https://github.com/CodeYourFuture/js-exercises). - -2. Signup to [CodeWars](https://codewars.com) and work on these challenges: - -*Functions, types, conditionals etc...* - -- [even or odd](https://www.codewars.com/kata/even-or-odd/train/javascript) -- [code under pressure](https://www.codewars.com/kata/you-cant-code-under-pressure-number-1/train/javascript) -- [secret message](https://www.codewars.com/kata/jennys-secret-message/train/javascript) -- [convert boolean](https://www.codewars.com/kata/convert-boolean-values-to-strings-yes-or-no/train/javascript) -- [opposite number](https://www.codewars.com/kata/opposite-number/train/javascript) -- [return negative](https://www.codewars.com/kata/return-negative/train/javascript) -- [hydrated](https://www.codewars.com/kata/keep-hydrated-1/train/javascript) -- [bonus](https://www.codewars.com/kata/do-i-get-a-bonus/train/javascript) -- [remove string spaces](https://www.codewars.com/kata/remove-string-spaces/train/javascript) -- [remove first and last character](https://www.codewars.com/kata/remove-first-and-last-character/train/javascript) -- [string repeat](https://www.codewars.com/kata/string-repeat/train/javascript) -- [mathematical operations](https://www.codewars.com/kata/basic-mathematical-operations/train/javascript) - -*Arrays* - -- [invert values](https://www.codewars.com/kata/invert-values/train/javascript) -- [needle in haystack](https://www.codewars.com/kata/a-needle-in-the-haystack/train/javascript) -- [counting sheep](https://www.codewars.com/kata/counting-sheep-dot-dot-dot/train/javascript) -- [sum of positive](https://www.codewars.com/kata/sum-of-positive/train/javascript) -- [people in bus](https://www.codewars.com/kata/number-of-people-in-the-bus/train/javascript) -- [sum without highest and lowest](https://www.codewars.com/kata/sum-without-highest-and-lowest-number/train/javascript) -- [reveersed array of digits](https://www.codewars.com/kata/convert-number-to-reversed-array-of-digits/train/javascript) +# Codewars Exercises + +Today, you'll be using a platform called [CodeWars](https://codewars.com) to help you recap the materials you learnt in JS1. CodeWars is an excellent platform for going through interesting JavaScript exercises, and allows you to communicate with the wider community to learn about the best way of writing JavaScript code. + +1. Make sure you finish all the pending exercies in week-1, week-2 and week-3 of the [js-exercises repo](https://github.com/CodeYourFuture/js-exercises). + +2. Signup to [CodeWars](https://codewars.com) and work on these challenges: + +*Functions, types, conditionals etc...* + +- [even or odd](https://www.codewars.com/kata/even-or-odd/train/javascript) +- [code under pressure](https://www.codewars.com/kata/you-cant-code-under-pressure-number-1/train/javascript) +- [secret message](https://www.codewars.com/kata/jennys-secret-message/train/javascript) +- [convert boolean](https://www.codewars.com/kata/convert-boolean-values-to-strings-yes-or-no/train/javascript) +- [opposite number](https://www.codewars.com/kata/opposite-number/train/javascript) +- [return negative](https://www.codewars.com/kata/return-negative/train/javascript) +- [hydrated](https://www.codewars.com/kata/keep-hydrated-1/train/javascript) +- [bonus](https://www.codewars.com/kata/do-i-get-a-bonus/train/javascript) +- [remove string spaces](https://www.codewars.com/kata/remove-string-spaces/train/javascript) +- [remove first and last character](https://www.codewars.com/kata/remove-first-and-last-character/train/javascript) +- [string repeat](https://www.codewars.com/kata/string-repeat/train/javascript) +- [mathematical operations](https://www.codewars.com/kata/basic-mathematical-operations/train/javascript) + +*Arrays* + +- [invert values](https://www.codewars.com/kata/invert-values/train/javascript) +- [needle in haystack](https://www.codewars.com/kata/a-needle-in-the-haystack/train/javascript) +- [counting sheep](https://www.codewars.com/kata/counting-sheep-dot-dot-dot/train/javascript) +- [sum of positive](https://www.codewars.com/kata/sum-of-positive/train/javascript) +- [people in bus](https://www.codewars.com/kata/number-of-people-in-the-bus/train/javascript) +- [sum without highest and lowest](https://www.codewars.com/kata/sum-without-highest-and-lowest-number/train/javascript) +- [reveersed array of digits](https://www.codewars.com/kata/convert-number-to-reversed-array-of-digits/train/javascript) - [slash sum of negatives](https://www.codewars.com/kata/count-of-positives-slash-sum-of-negatives/train/javascript) \ No newline at end of file diff --git a/week-3/.archive/A-array-find/README.md b/week-3/Homework/A-array-find/README.md similarity index 100% rename from week-3/.archive/A-array-find/README.md rename to week-3/Homework/A-array-find/README.md diff --git a/week-3/.archive/A-array-find/exercise.js b/week-3/Homework/A-array-find/exercise.js similarity index 100% rename from week-3/.archive/A-array-find/exercise.js rename to week-3/Homework/A-array-find/exercise.js diff --git a/week-3/.archive/B-array-some/README.md b/week-3/Homework/B-array-some/README.md similarity index 100% rename from week-3/.archive/B-array-some/README.md rename to week-3/Homework/B-array-some/README.md diff --git a/week-3/.archive/B-array-some/exercise.js b/week-3/Homework/B-array-some/exercise.js similarity index 100% rename from week-3/.archive/B-array-some/exercise.js rename to week-3/Homework/B-array-some/exercise.js diff --git a/week-3/.archive/C-array-every/README.md b/week-3/Homework/C-array-every/README.md similarity index 100% rename from week-3/.archive/C-array-every/README.md rename to week-3/Homework/C-array-every/README.md diff --git a/week-3/.archive/C-array-every/exercise.js b/week-3/Homework/C-array-every/exercise.js similarity index 100% rename from week-3/.archive/C-array-every/exercise.js rename to week-3/Homework/C-array-every/exercise.js diff --git a/week-3/.archive/D-array-filter/README.md b/week-3/Homework/D-array-filter/README.md similarity index 100% rename from week-3/.archive/D-array-filter/README.md rename to week-3/Homework/D-array-filter/README.md diff --git a/week-3/.archive/D-array-filter/exercise.js b/week-3/Homework/D-array-filter/exercise.js similarity index 100% rename from week-3/.archive/D-array-filter/exercise.js rename to week-3/Homework/D-array-filter/exercise.js diff --git a/week-3/.archive/E-array-map/README.md b/week-3/Homework/E-array-map/README.md similarity index 100% rename from week-3/.archive/E-array-map/README.md rename to week-3/Homework/E-array-map/README.md diff --git a/week-3/.archive/E-array-map/exercise.js b/week-3/Homework/E-array-map/exercise.js similarity index 100% rename from week-3/.archive/E-array-map/exercise.js rename to week-3/Homework/E-array-map/exercise.js diff --git a/week-3/.archive/F-array-forEach/README.md b/week-3/Homework/F-array-forEach/README.md similarity index 100% rename from week-3/.archive/F-array-forEach/README.md rename to week-3/Homework/F-array-forEach/README.md diff --git a/week-3/.archive/F-array-forEach/exercise.js b/week-3/Homework/F-array-forEach/exercise.js similarity index 100% rename from week-3/.archive/F-array-forEach/exercise.js rename to week-3/Homework/F-array-forEach/exercise.js diff --git a/week-3/Homework/G-extra/1-map.js b/week-3/Homework/G-extra/1-map.js new file mode 100644 index 000000000..453b67a91 --- /dev/null +++ b/week-3/Homework/G-extra/1-map.js @@ -0,0 +1,21 @@ +/* + I am new to London and would like to know what transport I can take to different famous locations. + An array with London locations have been provided. + Using .filter(), .map(), and any other array methods required, create: + - a new array of stations with travel by river boat + Note: only the names should be printed, not the means of transport. +*/ + +var stationTransportOptionsPairs = [ + ["Angel", ["tube", "bus"]], + ["London Bridge", ["tube", "bus", "river boat"]], + ["Tower bridge", ["tube", "bus"]], + ["Greenwich", ["tube", "bus", "river boat"]] +]; + +var stationsWithRiverBoat; // <-- Complete this statement + +console.log(stationsWithRiverBoat); + +// Expected output: +// ["London Bridge", "Greenwich"] diff --git a/week-3/Homework/G-extra/2-map.js b/week-3/Homework/G-extra/2-map.js new file mode 100644 index 000000000..a9ea412d2 --- /dev/null +++ b/week-3/Homework/G-extra/2-map.js @@ -0,0 +1,24 @@ +/* + Only students who have attended enough classes are eligible to sit an exam. + You have an array named `attendanceCounts` which contains all the students' names and their attendance counts. + Using .filter() and .map(), create a new array named "eligibleStudentNames" containing: + - only the NAMES of the students who have attended AT LEAST 8 classes. +*/ + +var attendanceCounts = [ + ["Ahmed", 8], + ["Clement", 10], + ["Elamin", 6], + ["Adam", 7], + ["Tayoa", 11], + ["Nina", 10] +]; + +var eligibleStudentNames; // TODO: Complete this line. + +console.log(eligibleStudentNames); + +/* expected output +[ 'Ahmed', 'Clement', 'Tayoa', 'Nina' ] +Note: student attendance counts should NOT be included in your console output. +*/ diff --git a/week-3/Homework/G-extra/3-filter.js b/week-3/Homework/G-extra/3-filter.js new file mode 100644 index 000000000..263b14e0f --- /dev/null +++ b/week-3/Homework/G-extra/3-filter.js @@ -0,0 +1,560 @@ +/* + You are given a list of some London street names. + We would like to know all of the names which contain 'Lane' their name. +*/ + +var streetNames = [ + "Abchurch Lane", + "Adam's Court", + "Addle Hill", + "Addle Street", + "Alban Highwalk", + "Albion Place", + "Albion Way", + "Aldermanbury", + "Alderman's Walk", + "Aldersgate Court", + "Aldgate", + "Allhallows Lane", + "Amen Corner", + "America Square", + "Andrewes Highwalk", + "Angel Court", + "Angel Lane", + "Angel Street", + "Apothecary Street", + "Appold Stree", + "The Arcade", + "Arthur Street", + "Artillery Lane", + "Artizan Street", + "Ashentree Court", + "Athene Place", + "Austin Friars", + "Ave Maria Lane", + "The Avenue", + "Back Alley", + "Back Passage", + "Bakers Hall Court", + "Ball Court", + "Baltic Street West", + "Barbon Alley", + "Barley Mow Passage", + "Barnard's Inn", + "Bartholomew Close", + "Bartholomew Lane", + "Bartlett Court", + "Basinghall Avenue", + "Bassishaw Highwalk", + "Bastion Highwalk", + "Bear Alley", + "Beech Gardens", + "Beehive Passage", + "Bengal Court", + "Bell Court", + "Bell Inn Yard", + "Bell Wharf Lane", + "Ben Jonson Place", + "Bennet's Hill", + "Bevis Marks", + "Billiter Court", + "Birchin Lane", + "Bishop's Court", + "Bishopsgate", + "Blackfriars Bridge", + "Blackfriars Court", + "Blackfriars Lane", + "Blackfriars Passage", + "Blomfield Street", + "Bloomberg Arcade", + "Bolt Court", + "Bond Court", + "Booth Lane", + "Botolph Alley", + "Bouverie Street", + "Bow Churchyard", + "Brabant Court", + "Brackley Street", + "Braidwood Passage", + "Brandon Mews", + "Bread Street", + "Bream's Buildings", + "Breton Highwalk", + "Brewer's Hall Gardens", + "Brick Court", + "Bride Court", + "Bridewell Place", + "Bridgewater Highwalk", + "Britannic Highwalk", + "Broadgate", + "Broad Lane", + "Broken Wharf", + "Brown's Buildings", + "Brushfield Street", + "Bucklersbury", + "Budge Row", + "Bull's Head Passage", + "Bunyan Court", + "Burgon Street", + "Bury Court", + "Bush Lane", + "Byward Street", + "Camomile Street", + "Canon Alley", + "Cannon Street", + "Capel Court", + "Carlisle Avenue", + "Carmelite Street", + "Carter Court", + "Carthusian Street", + "Castle Baynard Street", + "Castle Court", + "Catherine Wheel Alley", + "Cavendish Court", + "Chancery Lane", + "Change Alley", + "Charterhouse Square", + "Cheapside", + "Cheshire Court", + "Chiswell Street", + "Church Cloisters", + "Church Court", + "Church Entry", + "Circus Place", + "Clements Lane", + "Clerk's Place", + "Clifford's Inn Passage", + "Cloak Lane", + "Cloth Court", + "Clothier Street", + "Cobb's Court", + "Cock Hill", + "Cock Lane", + "Coleman Street", + "College Hill", + "Compter Passage", + "Cooper's Row", + "Copthall Avenue", + "Corbet Court", + "Cornhill", + "Cousin Lane", + "Cowper's Court", + "Crane Court", + "Creechurch Lane", + "Creed Court", + "Crescent", + "Cripplegate Street", + "Cromwell Highwalk", + "Crosby Square", + "Cross Keys Square", + "Cross Lane", + "Crosswall", + "Crown Court", + "Crown Office Row", + "Crutched Friars", + "Cullum Street", + "Cunard Place", + "Cursitor Street", + "Custom House Walk", + "Cutler Street", + "Dark House Walk", + "Dean's Court", + "Defoe Place", + "Devonshire Row", + "Distaff Lane", + "Doby Court", + "Dorset Buildings", + "Dowgate Hill", + "Drapers Gardens", + "Dukes Place", + "Dunster Court", + "Dyer's Buildings", + "Eastcheap", + "East Harding Street", + "East Passage", + "East Poultry Avenue", + "Eldon Street", + "Elm Court", + "Essex Court", + "Exchange Arcade", + "Falcon Court", + "Falcon Highwalk", + "Fann Street", + "Farringdon Street", + "Fen Court", + "Fetter Lane", + "Finch Lane", + "Finsbury Avenue", + "Fish Street Hill", + "Fishmongers Hall Wharf", + "Fleet Place", + "Fore Street", + "Fort Street", + "Foster Lane", + "Founders' Court", + "Fountain Court", + "Frederick's Place", + "French Ordinary Court", + "Friar Street", + "Friday Street", + "Frobisher Crescent", + "Fruiterers Passage", + "Furnival Street", + "Fye Foot Lane", + "Garden Court", + "Gardner's Lane", + "Garlick Hill", + "George Yard", + "Giltspur Street", + "Gloucester Court", + "Godliman Street", + "Golden Lane", + "Goldsmith Street", + "Goodman's Court", + "Gophir Lane", + "Goring Street", + "Goswell Road", + "Gough Square", + "Gracechurch Street", + "Grand Avenue", + "Grant's Quay Wharf", + "Gravel Lane", + "Great Bell Alley", + "Great Eastern Walk", + "Great New Street", + "Great St Helen's", + "Great St Thomas Apostle", + "Great Swan Alley", + "Great Tower Street", + "Great Trinity Lane", + "Great Winchester Street", + "Green Arbour Court", + "The Green Yard", + "Gresham Street", + "Greyfriars Passage", + "Greystoke Place", + "Grocer's Hall Court", + "Groveland Court", + "Guildhall Buildings", + "Guinness Court", + "Gunpowder Square", + "Gutter Lane", + "Half Moon Court", + "Hammett Street", + "Hanging Sword Alley", + "Hanseatic Walk", + "Hare Place", + "Harp Alley", + "Harp Lane", + "Harrow Place", + "Hart Street", + "Hartshorn Alley", + "Haydon Street", + "Hayne Street", + "Hen", + "Heneage Lane", + "High Holborn", + "High Timber Street", + "Hind Court", + "Hogarth Court", + "Honey Lane", + "Hood Court", + "Hope Square", + "Hosier Lane", + "Houndsditch", + "Huggin Court", + "Hutton Street", + "Idol Lane", + "India Street", + "Inner Temple Lane", + "Ireland Yard", + "Ironmonger Lane", + "Jewry Street", + "John Carpenter Street", + "John Milton Passage", + "John Trundle Highwalk", + "John Wesley Highwalk", + "Johnsons Court", + "Keats Place", + "Kennett Wharf Lane", + "Kinghorn Street", + "Kingscote Street", + "King Street", + "King Edward Street", + "King William Street", + "King's Arms Yard", + "King's Bench Walk", + "Knightrider Court", + "Lakeside Terrace", + "Lambert Jones Mews", + "Lambeth Hill", + "Langthorn Court", + "Lauderdale Place", + "Laurence Pountney Hill", + "Lawrence Lane", + "Leadenhall Market", + "Lime Street", + "Limeburner Lane", + "Lindsey Street", + "Little Britain", + "Little Somerset Street", + "Liverpool Street", + "Lloyd's Avenue", + "Lombard Court", + "Lombard Street", + "London Bridge", + "London Street", + "London Wall", + "Long Lane", + "Lothbury", + "Lovat Street", + "Love Lane", + "Lower Thames Street", + "Ludgate Broadway", + "Mac's Place", + "Magpie Alley", + "Mansell Street", + "Mansion House Place", + "Mark Lane", + "Martin Lane", + "Mason's Avenue", + "Middle Street", + "Middlesex Passage", + "Middlesex Street", + "Middle Temple Lane", + "Milk Street", + "Millennium Bridge", + "Milton Court", + "Mincing Lane", + "Minerva Walk", + "Miniver Place", + "Minories", + "Minster Court", + "Mitre Square", + "Modern Court", + "Monkwell Square", + "Montague Street", + "Monument Street", + "Moorfields", + "Moorgate", + "Moor Lane", + "Muscovy Street", + "Nettleton Court", + "Nevill Lane", + "New Bell Yard", + "New Bridge Street", + "Newbury Street", + "Newcastle Close", + "Newcastle Court", + "New Change", + "New Court", + "Newgate Street", + "Newman's Court", + "New Street", + "New Union Street", + "Nicholas Lane", + "Noble Street", + "Northumberland Alley", + "Norton Folgate", + "Norwich Street", + "Nun Court", + "Oat Lane", + "Octagon Arcade", + "Old Bailey", + "Old Billingsgate Walk", + "Old Jewry", + "Old Mitre Court", + "Old Seacole Lane", + "Old Watermen's Walk", + "Outwich Street", + "Oystergate Walk", + "Oxford Court", + "Pageantmaster Court", + "Pancras Lane", + "Panyer Alley", + "Paternoster Lane", + "Paul's Walk", + "Pemberton Row", + "Pepys Street", + "Peterborough Court", + "Peter's Hill", + "Petty Wales", + "Philpot Lane", + "Pilgrim Street", + "Pindar Street", + "Pinner's Passage", + "Plaisterers Highwalk", + "Plantation Lane", + "Playhouse Yard", + "Pleydell Court", + "Plough Court", + "Plough Place", + "Plumtree Court", + "Pope's Head Alley", + "Poppins Court", + "Portsoken Street", + "Post Office Court", + "Poultry", + "Priest's Court", + "Primrose Hill", + "Primrose Street", + "Prince's Street", + "Printers Inn Court", + "Printer Street", + "Priory Court", + "Prudent Passage", + "Pudding Lane", + "Puddle Dock", + "Pump Court", + "Quality Court", + "Queenhithe", + "Queen Isabella Way", + "Queens Head Passage", + "Queen Street", + "Queen Victoria Street", + "Rangoon Street", + "Red Lion Court", + "Regent Street", + "Rising Sun Court", + "Robin Hood Court", + "Rolls Buildings", + "Rood Lane", + "Ropemaker Street", + "Rose Alley", + "Rose", + "Rose Street", + "Royal Exchange Avenue", + "Russia Row", + "St Alphage Garden", + "St Andrew Street", + "St Andrew's Hill", + "St Benet's Place", + "St Botolph Row", + "St Clare Street", + "St Dunstan's Alley", + "St Dunstan's Court", + "St Georges Court", + "St Giles Terrace", + "St James's Passage", + "St Katherine's Row", + "St Margaret's Close", + "St Martin's le Grand", + "St Mary at Hill", + "St Mary Axe", + "St Michael's Alley", + "St Mildred's Court", + "St Olave's Court", + "St Paul's Churchyard", + "St Peter's Alley", + "St Swithins Lane", + "Salisbury Court", + "Salters Court", + "Salter's Hall Court", + "Sandy's Row", + "Saracens Head Yard", + "Savage Gardens", + "Scott's Lane", + "Seething Lane", + "Serjeants Inn", + "Sermon Lane", + "Shafts Court", + "Sherborne Lane", + "Ship Tavern Passage", + "Shoe Lane", + "Shorter Street", + "Silk Street", + "Sise Lane", + "Skinners Lane", + "Smithfield Street", + "Snow Hill", + "Southampton Buildings", + "South Place", + "Southwark Bridge", + "Speed Highwalk", + "Staining Lane", + "Staple Inn", + "Star Alley", + "Stationer's Hall Court", + "Steelyard Passage", + "Stew Lane", + "Stonecutter Street", + "Stone House Court", + "Stoney Lane", + "Suffolk Lane", + "Sugar Bakers Court", + "Sugar Quay Walk", + "Sun Court", + "Sun Street", + "Swan Lane", + "Swedeland Court", + "Talbot Court", + "Tallis Street", + "Telegraph Street", + "Temple Avenue", + "The Terrace", + "Thavies Inn", + "Thomas More Highwalk", + "Threadneedle Street", + "Three Barrels Walk", + "Three Cranes Walk", + "Three Nun Court", + "Three Quays Walk", + "Throgmorton Avenue", + "Tokenhouse Yard", + "Took's Court", + "Tower Hill Terrace", + "Tower Royal", + "Trig Lane", + "Trinity Square", + "Trump Street", + "Tudor Street", + "Turnagain Lane", + "Undershaft", + "Union Court", + "Victoria Avenue", + "Victoria Embankment", + "Vine Street", + "Vintners Court", + "Viscount Street", + "Waithman Street", + "Walbrook", + "Wardrobe Place", + "Warwick Lane", + "Watergate", + "Water Lane", + "Watling Court", + "Well Court", + "Whalebone Court", + "Whitecross Place", + "Whitecross Street", + "Whitefriars Street", + "White Hart Court", + "White Hart Street", + "White Horse Yard", + "White Kennett Street", + "White Lion Court", + "White Lion Hill", + "White Lyon Court", + "Whittington Avenue", + "Widegate Street", + "Willoughby Highwalk", + "Wilson Street", + "Wine Office Court", + "Wood Street", + "Wormwood Street", + "Wrestler's Court" +]; + +var laneNames; // Complete this line + +console.log(laneNames); +console.log(laneNames.length); + +/* EXPECTED OUTPUT +---------------------- +[ 'Abchurch Lane', + 'Allhallows Lane', + ... many more ... + 'Water Lane' ] +74 +*/ From 8499fee4ae12cef5775dbf0341e9afca208c6002 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Sun, 24 May 2020 18:00:45 +0100 Subject: [PATCH 14/37] restructure homework --- week-4/Homework/extra/extra-homework.md | 14 +----- week-4/Homework/mandatory/1-food.js | 39 ++++++++++++++++ week-4/Homework/mandatory/1-freecodecamp.md | 20 --------- week-4/Homework/mandatory/2-writers.js | 10 ++--- week-4/Homework/mandatory/3-groceries.js | 44 +++++++++++++++++++ week-4/Homework/mandatory/4-groceries.js | 12 ----- .../{3-water-bottle.js => 4-water-bottle.js} | 16 +++---- week-4/Homework/mandatory/5-codewars.md | 17 ------- week-4/Homework/mandatory/5-hackername.js | 4 ++ 9 files changed, 102 insertions(+), 74 deletions(-) create mode 100644 week-4/Homework/mandatory/1-food.js delete mode 100644 week-4/Homework/mandatory/1-freecodecamp.md create mode 100644 week-4/Homework/mandatory/3-groceries.js delete mode 100644 week-4/Homework/mandatory/4-groceries.js rename week-4/Homework/mandatory/{3-water-bottle.js => 4-water-bottle.js} (77%) delete mode 100644 week-4/Homework/mandatory/5-codewars.md create mode 100644 week-4/Homework/mandatory/5-hackername.js diff --git a/week-4/Homework/extra/extra-homework.md b/week-4/Homework/extra/extra-homework.md index 4aa5066a0..1cda1120d 100644 --- a/week-4/Homework/extra/extra-homework.md +++ b/week-4/Homework/extra/extra-homework.md @@ -6,17 +6,7 @@ Click "ATTEMPT" to test your solution. Exercises: +- [Job Matching #1](https://www.codewars.com/kata/56c22c5ae8b139416c00175d/train/javascript) +- [Split the Bill](https://www.codewars.com/kata/5641275f07335295f10000d0/train/javascript) - [Fix my Method](https://www.codewars.com/kata/558710234f02dcc4a8000005) - [Regular Ball Super Ball](https://www.codewars.com/kata/53f0f358b9cb376eca001079/train/javascript) - -## Reading - -1.['You Don't Know JS: this & Object Prototypes' - Chapter 3, 'Objects'](https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/this%20%26%20object%20prototypes/ch3.md) - -2. Eloquent JavaScript Chapter 4 - 'Data Structures: Objects and Arrays': https://eloquentjavascript.net/04_data.html -3. Eloquent JavaScript Chapter 6 - 'The Secret Life of Objects': https://eloquentjavascript.net/06_object.html - -## Viewing - -1. [Methods and 'this' keyword in JavaScript](https://www.youtube.com/watch?v=0wN-L9CG3y0) -2. [Modern JavaScript Tutorial #5 - Objects](https://www.youtube.com/watch?v=X0ipw1k7ygU) diff --git a/week-4/Homework/mandatory/1-food.js b/week-4/Homework/mandatory/1-food.js new file mode 100644 index 000000000..d3c909787 --- /dev/null +++ b/week-4/Homework/mandatory/1-food.js @@ -0,0 +1,39 @@ +//TODO think about exercises for this + +let myFavFood = { + name: "falafel wrap", + isVeggie: true, + caloriesPerPortion: 550, + ingredients: ["chickpeas", "cumin", "oil", "sesame seeds", "tahini sauce"], + takeAway: { + name: "falafel to go", + address: "Hope St. Glasgow", + }, +}; + +console.log(`Favorite food ${myFavFood.name}`); + +function prepareFood(food) { + console.log( + `I need to buy these ingredients first: ${food.ingredients.join(",")}` + ); +} + +function buy(food) { + console.log(`I am on my way to ${food.takeAway.name}`); +} + +function isItVeggie(food) { + if (food.isVeggie) { + console.log(`${food.name} is a veggie dish`); + } else { + console.log(`${food.name} is NOT a veggie dish`); + } +} +function isItGoodForDiet(food) { + return food.calPerPortion < 600; +} +prepareFood(myFavFood); +buy(myFavFood); +isItVeggie(myFavFood); +console.log("Is my favorite food good for my diet: " + goodForDiet(myFavFood)); diff --git a/week-4/Homework/mandatory/1-freecodecamp.md b/week-4/Homework/mandatory/1-freecodecamp.md deleted file mode 100644 index a05de7191..000000000 --- a/week-4/Homework/mandatory/1-freecodecamp.md +++ /dev/null @@ -1,20 +0,0 @@ -## FreeCodeCamp Lessons - -Complete all 26 of the 'Object Oriented Programming' lessons on FreeCodeCamp at https://www.freecodecamp.org/learn - -- Introduction to the Object Oriented Programming Challenges -- Create a Basic JavaScript Object -- Use Dot Notation to Access the Properties of an Object -- Create a Method on an Object -- Make Code More Reusable with the this Keyword -- Define a Constructor Function -- Use a Constructor to Create Objects -- Extend Constructors to Receive Arguments -- Verify an Object's Constructor with instanceof -- Understand Own Properties -- Use Prototype Properties to Reduce Duplicate Code -- Iterate Over All Properties -- Understand the Constructor Property -- Change the Prototype to a New Object -- Remember to Set the Constructor Property when Changing the Prototype -- Understand Where an Object’s Prototype Comes From diff --git a/week-4/Homework/mandatory/2-writers.js b/week-4/Homework/mandatory/2-writers.js index 974a173aa..a071ef0bb 100644 --- a/week-4/Homework/mandatory/2-writers.js +++ b/week-4/Homework/mandatory/2-writers.js @@ -14,29 +14,29 @@ let writers = [ lastName: "Woolf", occupation: "writer", age: 59, - alive: false + alive: false, }, { firstName: "Zadie", lastName: "Smith", occupation: "writer", age: 41, - alive: true + alive: true, }, { firstName: "Jane", lastName: "Austen", occupation: "writer", age: 41, - alive: false + alive: false, }, { firstName: "bell", lastName: "hooks", occupation: "writer", age: 64, - alive: true - } + alive: true, + }, ]; /* diff --git a/week-4/Homework/mandatory/3-groceries.js b/week-4/Homework/mandatory/3-groceries.js new file mode 100644 index 000000000..33c6769dd --- /dev/null +++ b/week-4/Homework/mandatory/3-groceries.js @@ -0,0 +1,44 @@ +const languages = { + english: "Welcome", + czech: "Vitejte", + danish: "Velkomst", + dutch: "Welkom", + estonian: "Tere tulemast", + finnish: "Tervetuloa", + flemish: "Welgekomen", + french: "Bienvenue", + german: "Willkommen", + irish: "Failte", + italian: "Benvenuto", + latvian: "Gaidits", + lithuanian: "Laukiamas", + polish: "Witamy", + spanish: "Bienvenido", + swedish: "Valkommen", + welsh: "Croeso", +}; + +/* +Write a 'greet' function that takes a parameter 'language' (always a string), +and returns the greeting for that language - if it exists in your "languages" object. + +It should default to English if the language is not in your object of languages, +or in the event of an invalid input. +*/ + +function greet(language) { + //write your code here +} + +/* +Test your function works correctly calling it inside a console.log(), for each one of these cases: + +1. pass it a valid lowercase language + +For example: console.log(greet("irish")); + +2. pass it a valid uppercase language +3. pass it a language that doesn't exist in the object +4. pass it an invalid string (something that is not even a language) + +*/ diff --git a/week-4/Homework/mandatory/4-groceries.js b/week-4/Homework/mandatory/4-groceries.js deleted file mode 100644 index 2b34cdb53..000000000 --- a/week-4/Homework/mandatory/4-groceries.js +++ /dev/null @@ -1,12 +0,0 @@ -// You're going shopping, and you need a shopping list. -// 1. Update your groceryList with the items you need: Potatoes, Orange Juice and Rice. -// 2. Loop through the groceryList object to gather the item properties into the groceriesToBuy array. -// 3. Then use console.log() to print out the list. It should print ['Potatoes', 'Orange Juice', 'Rice'] - -let groceriesToBuy = []; - -let groceryList = { - item1: "", - item2: "", - item3: "" -}; diff --git a/week-4/Homework/mandatory/3-water-bottle.js b/week-4/Homework/mandatory/4-water-bottle.js similarity index 77% rename from week-4/Homework/mandatory/3-water-bottle.js rename to week-4/Homework/mandatory/4-water-bottle.js index cb8041140..6090e6595 100644 --- a/week-4/Homework/mandatory/3-water-bottle.js +++ b/week-4/Homework/mandatory/4-water-bottle.js @@ -9,16 +9,16 @@ We made a start on this for you here: */ let bottle = { - volume: 0, - fill: function() { + percentageFull: 0, + fill: function () { // calling this function should make you bottles volume = 100; }, - drink: function() { + drink: function () { // calling this function should decrease your bottles volume by 10; }, - empty: function() { + isEmpty: function () { // this function should return true if your bottles volume = 0 - } + }, }; /* @@ -35,7 +35,7 @@ bottle.fill(); bottle.drink(); bottle.drink(); bottle.drink(); -if (!bottle.empty()) { - console.log(`bottles volume = ${bottle.volume}`); +if (!bottle.isEmpty()) { + console.log(`Your bottle is ${bottle.volume}% full`); } -console.log("Above volume should be: 70"); +console.log("Above fill should be 70%"); diff --git a/week-4/Homework/mandatory/5-codewars.md b/week-4/Homework/mandatory/5-codewars.md deleted file mode 100644 index cc5c8e86b..000000000 --- a/week-4/Homework/mandatory/5-codewars.md +++ /dev/null @@ -1,17 +0,0 @@ -## Reading - -- [Understanding JavaScript Constructors](https://css-tricks.com/understanding-javascript-constructors/) - -## CodeWars Exercises - -Complete the following CodeWars exercises. Go to the webpages below and follow the instructions there. - -Click "ATTEMPT" to test your solution. - -Exercises: - -- [Training JS #5: Basic data types--Object](https://www.codewars.com/kata/571f1eb77e8954a812000837/train/javascript) -- [Welcome!](https://www.codewars.com/kata/welcome/train/javascript) -- [Crash Override](https://www.codewars.com/kata/crash-override/train/javascript) -- [Job Matching #1](https://www.codewars.com/kata/56c22c5ae8b139416c00175d/train/javascript) -- [Split the Bill](https://www.codewars.com/kata/5641275f07335295f10000d0/train/javascript) diff --git a/week-4/Homework/mandatory/5-hackername.js b/week-4/Homework/mandatory/5-hackername.js new file mode 100644 index 000000000..40a7deaa8 --- /dev/null +++ b/week-4/Homework/mandatory/5-hackername.js @@ -0,0 +1,4 @@ +//codewars hacker exercise +//https://www.codewars.com/kata/crash-override/train/javascript + +//TODO implement this From a64e1f386341c5012408254b5bd599c7ad086613 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Mon, 25 May 2020 21:57:41 +0100 Subject: [PATCH 15/37] simplify homework git remote -v --- week-4/Homework/extra/extra-homework.md | 3 +- week-4/Homework/mandatory/1-food.js | 56 +++++++++++-------- .../{3-groceries.js => 3-translator.js} | 0 week-4/Homework/mandatory/4-water-bottle.js | 41 -------------- week-4/Homework/mandatory/5-hackername.js | 4 -- 5 files changed, 35 insertions(+), 69 deletions(-) rename week-4/Homework/mandatory/{3-groceries.js => 3-translator.js} (100%) delete mode 100644 week-4/Homework/mandatory/4-water-bottle.js delete mode 100644 week-4/Homework/mandatory/5-hackername.js diff --git a/week-4/Homework/extra/extra-homework.md b/week-4/Homework/extra/extra-homework.md index 1cda1120d..00b116e4e 100644 --- a/week-4/Homework/extra/extra-homework.md +++ b/week-4/Homework/extra/extra-homework.md @@ -6,7 +6,6 @@ Click "ATTEMPT" to test your solution. Exercises: +- [Hackerwars](https://www.codewars.com/kata/crash-override/train/javascript) - [Job Matching #1](https://www.codewars.com/kata/56c22c5ae8b139416c00175d/train/javascript) - [Split the Bill](https://www.codewars.com/kata/5641275f07335295f10000d0/train/javascript) -- [Fix my Method](https://www.codewars.com/kata/558710234f02dcc4a8000005) -- [Regular Ball Super Ball](https://www.codewars.com/kata/53f0f358b9cb376eca001079/train/javascript) diff --git a/week-4/Homework/mandatory/1-food.js b/week-4/Homework/mandatory/1-food.js index d3c909787..58f525a12 100644 --- a/week-4/Homework/mandatory/1-food.js +++ b/week-4/Homework/mandatory/1-food.js @@ -1,5 +1,3 @@ -//TODO think about exercises for this - let myFavFood = { name: "falafel wrap", isVeggie: true, @@ -11,29 +9,43 @@ let myFavFood = { }, }; -console.log(`Favorite food ${myFavFood.name}`); +// 1. console.log() the name of myFavFood -function prepareFood(food) { - console.log( - `I need to buy these ingredients first: ${food.ingredients.join(",")}` - ); -} +console.log("Favorite food is " + myFavFood.name); + +// 2. Declare a function "getTakeAwayAddress" that accepts "food" as a parameter +// and returns the address of where to buy it -function buy(food) { - console.log(`I am on my way to ${food.takeAway.name}`); +function getTakeAwayAddress(food) { + // write code here } -function isItVeggie(food) { - if (food.isVeggie) { - console.log(`${food.name} is a veggie dish`); - } else { - console.log(`${food.name} is NOT a veggie dish`); - } +console.log("I can buy my favorite food from " + getTakeAwayAddress(myFavFood)); + +// 3. Declare a function "isVeggie" that accepts "food" as a parameter +// and returns true if it's vegetarian, or false if not + +function isVeggie(food) { + // write code here } -function isItGoodForDiet(food) { - return food.calPerPortion < 600; + +console.log("Is my favorite vegetarian? " + isVeggie(food)); + +// 3. Declare a function "isLowCalorie" that accepts "food" as a parameter +// and returns true if it has less than 600 calories, or false otherwise +// write your own console.log() that calls the function to test it, as in the examples above! +// no example code is provided here! + +//--------------------------------------- + +// 3. Declare a function "isSafeForNutAllergies" that accepts "food" as a parameter +// and returns false if it found the word "sesame" in the ingredients, or true otherwise + +function isSafeForNutAllergies(food) { + //write code here } -prepareFood(myFavFood); -buy(myFavFood); -isItVeggie(myFavFood); -console.log("Is my favorite food good for my diet: " + goodForDiet(myFavFood)); + +console.log( + "Is my favorite food nut allergy safe? ", + isSafeForNutAllergies(myFavFood) +); diff --git a/week-4/Homework/mandatory/3-groceries.js b/week-4/Homework/mandatory/3-translator.js similarity index 100% rename from week-4/Homework/mandatory/3-groceries.js rename to week-4/Homework/mandatory/3-translator.js diff --git a/week-4/Homework/mandatory/4-water-bottle.js b/week-4/Homework/mandatory/4-water-bottle.js deleted file mode 100644 index 6090e6595..000000000 --- a/week-4/Homework/mandatory/4-water-bottle.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -Create an object that acts like a water bottle. -It will need a volume key to store how full or empty the bottle is. -It will be 100 when full and 0 when empty. -Give your water bottle methods for filling it up, -drinking some of it, and emptying it. - -We made a start on this for you here: -*/ - -let bottle = { - percentageFull: 0, - fill: function () { - // calling this function should make you bottles volume = 100; - }, - drink: function () { - // calling this function should decrease your bottles volume by 10; - }, - isEmpty: function () { - // this function should return true if your bottles volume = 0 - }, -}; - -/* ---TIP-- - -Remember that for changing properties on the current object inside one of its -methods you can refer to it by its variable name: `bottle`. - -Once you have completed your object run the following and see if your answer -matches the expected result at the bottom :) -*/ - -bottle.fill(); -bottle.drink(); -bottle.drink(); -bottle.drink(); -if (!bottle.isEmpty()) { - console.log(`Your bottle is ${bottle.volume}% full`); -} -console.log("Above fill should be 70%"); diff --git a/week-4/Homework/mandatory/5-hackername.js b/week-4/Homework/mandatory/5-hackername.js deleted file mode 100644 index 40a7deaa8..000000000 --- a/week-4/Homework/mandatory/5-hackername.js +++ /dev/null @@ -1,4 +0,0 @@ -//codewars hacker exercise -//https://www.codewars.com/kata/crash-override/train/javascript - -//TODO implement this From dd6f0dc6485d5503a6b27f579011465ec0d69f2d Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Mon, 25 May 2020 22:17:57 +0100 Subject: [PATCH 16/37] remote this keyword from homework --- week-4/InClass/D-methods/README.md | 64 +++----------------------- week-4/InClass/D-methods/exercise-3.js | 28 ----------- week-4/InClass/D-methods/exercise-4.js | 19 -------- week-4/InClass/D-methods/exercise-5.js | 43 ----------------- 4 files changed, 7 insertions(+), 147 deletions(-) delete mode 100644 week-4/InClass/D-methods/exercise-3.js delete mode 100644 week-4/InClass/D-methods/exercise-4.js delete mode 100644 week-4/InClass/D-methods/exercise-5.js diff --git a/week-4/InClass/D-methods/README.md b/week-4/InClass/D-methods/README.md index 7c65fe76e..fee6a85a2 100644 --- a/week-4/InClass/D-methods/README.md +++ b/week-4/InClass/D-methods/README.md @@ -1,69 +1,19 @@ ### Object methods -Besides having specific properties, objects in the real world can also do things. For example, a computer can display something on the screen, a person can say their names etc... In Javascript, we do this using 'methods'. A method is a function attached to a particular object. You have already used some predefined methods before, for example *toUpperCase()* on a string or *filter()* on an array. +Besides having specific properties, objects in the real world can also do things. For example, a computer can display something on the screen, a person can say their names etc... In Javascript, we do this using 'methods'. A method is a function attached to a particular object. You have already used some predefined methods before, for example _toUpperCase()_ on a string or _filter()_ on an array. ```js let athlete = { - name: 'Usain Bolt', - goldMedals: 25, - sayHi: function() { - return "Hi everybody!"; - } + name: "Usain Bolt", + goldMedals: 25, + sayHi: function () { + return "Hi everybody!"; + }, }; ``` -How do we call this method? +How do we call this method? ```js athlete.sayHi(); // returns "Hi everybody!" ``` - -An object method can also rely on the other properties of the object to do more complex calculation. To reference the current object in the body of the method, we will use the keyword *this*. Let's take an example. - -```js -let athlete = { - name: 'Usain Bolt', - goldMedals: 25, - sayName: function() { - return "My name is " + this.name; - } -}; - -athlete.sayName(); // returns "My name is Usain Bolt" -``` - -Knowing this, you can have methods which modify existing properties of your object. - -```js -let athlete = { - name: 'Usain Bolt', - goldMedals: 25, - winNewMedal: function() { - this.goldMedals = this.goldMedals + 1; - } -}; - -athlete.winNewMedal(); -console.log(athelete.goldMedals); // prints "26" -``` - -As methods are just functions attached to objects, they can also take parameters. - -```js -let athlete = { - name: 'Usain Bolt', - goldMedals: 25, - silverMedals: 7, - winNewMedal: function(medal) { - if (medal === "gold") { - this.goldMedals = this.goldMedals + 1; - } else { - this.silverMedals = this.silverMedals + 1; - } - } -}; - -athlete.winNewMedal("silver"); -console.log(athlete.goldMedals); // prints "25" -console.log(athlete.silverMedals); // prints "8" -``` \ No newline at end of file diff --git a/week-4/InClass/D-methods/exercise-3.js b/week-4/InClass/D-methods/exercise-3.js deleted file mode 100644 index be237483b..000000000 --- a/week-4/InClass/D-methods/exercise-3.js +++ /dev/null @@ -1,28 +0,0 @@ -/* -The following code contains syntax errors - try and fix them! -Once you fix them, run this file, it should output the correct values! -*/ - - -let person = { - name: "Alice", - age: 25, - currentAddress: "Glasgow", - changeAddress: (newAddress) { - currentAddress = newAddress; - }, - celebrateBirthday: function { - that.age = that.age + 1; - } -}; - - -/* -DO NOT EDIT ANYTHING BELOW THIS LINE -*/ - -person.changeAddress("Edinburgh"); -console.log(`Expected result: Edinburgh. Actual result: ${person.currentAddress}`); - -person.celebrateBirthday(); -console.log(`Expected result: 26. Actual result: ${person.age}`); diff --git a/week-4/InClass/D-methods/exercise-4.js b/week-4/InClass/D-methods/exercise-4.js deleted file mode 100644 index d89214a72..000000000 --- a/week-4/InClass/D-methods/exercise-4.js +++ /dev/null @@ -1,19 +0,0 @@ -/* -Alice has a list of good friends. -Define a method "makeFriend" to add a new friend to her list. -*/ - - -let person = { - name: "Alice", - friends: ["John", "Nina"] -}; - - -/* -DO NOT EDIT ANYTHING BELOW THIS LINE -*/ - -person.makeFriend("Bob"); - -console.log(`Expected result: 'John,Nina,Bob'. Actual result: ${person.friends}`); \ No newline at end of file diff --git a/week-4/InClass/D-methods/exercise-5.js b/week-4/InClass/D-methods/exercise-5.js deleted file mode 100644 index dcd198c47..000000000 --- a/week-4/InClass/D-methods/exercise-5.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -A coffee machine is defined below. -One can buy three different coffees. -Complete the methods "insertMoney" and "getCoffee" to match the expected result. - -insertMoney takes an amount in parameter to add money in the coffee machine. -getCoffee takes a coffee type in parameter and dispends the selected coffee -only if the inserted amount is greater or equal than the price of the coffee! -*/ - -let coffeeMachine = { - brand: "Super Coffee", - prices: { - cappuccino: 2.40, - blackCoffee: 1.50, - flatWhite: 3.00 - }, - insertedAmount: 0, - insertMoney: function (amount) { - - }, - getCoffee: function (coffee) { - - } -}; - - -/* -DO NOT EDIT ANYTHING BELOW THIS LINE -*/ - -coffeeMachine.insertMoney(2.40); -console.log(`Expected result: 'Please take your cappuccino'. Actual result: ${coffeeMachine.getCoffee('cappuccino')}`); - -coffeeMachine.insertMoney(1.50); -console.log(`Expected result: 'Please take your blackCoffee'. Actual result: ${coffeeMachine.getCoffee('blackCoffee')}`); - -coffeeMachine.insertMoney(4.00); -console.log(`Expected result: 'Please take your flatWhite'. Actual result: ${coffeeMachine.getCoffee('flatWhite')}`); - -coffeeMachine.insertMoney(2.40); -console.log(`Expected result: 'Sorry you don't have enough money for a flatWhite'. Actual result: ${coffeeMachine.getCoffee('flatWhite')}`); - From c603c7b62d83ab0b0d828af5738c1d6d0f41ad3d Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 29 May 2020 22:57:19 +0100 Subject: [PATCH 17/37] update homework --- week-4/InClass/D-methods/exercise-2.js | 11 ++- .../InClass/E-arrays-of-objects/exercise-3.js | 90 +++++++++---------- .../G-loop-through-objects/exercise1.js | 13 +++ 3 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 week-4/InClass/G-loop-through-objects/exercise1.js diff --git a/week-4/InClass/D-methods/exercise-2.js b/week-4/InClass/D-methods/exercise-2.js index 8e993fc69..acc52024e 100644 --- a/week-4/InClass/D-methods/exercise-2.js +++ b/week-4/InClass/D-methods/exercise-2.js @@ -1,18 +1,17 @@ /* A person named Alice is defined below. Add a method "sayName" so this person can say their own name. -Hint: use 'this' keyword to access the name property. */ - let person = { - name: "Alice", - age: 25 + name: "Alice", + age: 25, }; - /* DO NOT EDIT ANYTHING BELOW THIS LINE */ -console.log(`Expected result: 'My name is Alice'. Actual result: ${person.sayName()}`); \ No newline at end of file +console.log( + `Expected result: 'My name is Alice'. Actual result: ${person.sayName()}` +); diff --git a/week-4/InClass/E-arrays-of-objects/exercise-3.js b/week-4/InClass/E-arrays-of-objects/exercise-3.js index a1ec6916f..282765543 100644 --- a/week-4/InClass/E-arrays-of-objects/exercise-3.js +++ b/week-4/InClass/E-arrays-of-objects/exercise-3.js @@ -15,36 +15,36 @@ and returns the number of restaurants in this area. */ let restaurant1 = { - name: "Paesano", - totalSeats: 10, - numberOfCustomers: 8, - address: { - city: "Glasgow", - area: "center" - }, - menu: ["pizza", "calzone", "salad"] + name: "Paesano", + totalSeats: 10, + numberOfCustomers: 8, + address: { + city: "Glasgow", + area: "center", + }, + menu: ["pizza", "calzone", "salad"], }; let restaurant2 = { - name: "Ubiquitous Chip", - totalSeats: 20, - numberOfCustomers: 10, - address: { - city: "Glasgow", - area: "west" - }, - menu: ["salad", "chocolate cake", "roast lamb"] + name: "Ubiquitous Chip", + totalSeats: 20, + numberOfCustomers: 10, + address: { + city: "Glasgow", + area: "west", + }, + menu: ["salad", "chocolate cake", "roast lamb"], }; let restaurant3 = { - name: "Monkeyz", - totalSeats: 15, - numberOfCustomers: 8, - address: { - city: "Glasgow", - area: "center" - }, - menu: ["stew", "chocolate cake", "panini"] + name: "Monkeyz", + totalSeats: 15, + numberOfCustomers: 8, + address: { + city: "Glasgow", + area: "center", + }, + menu: ["stew", "chocolate cake", "panini"], }; let restaurants = [restaurant1, restaurant2, restaurant3]; @@ -54,32 +54,24 @@ DO NOT EDIT ANYTHING ABOVE THIS LINE WRITE YOUR CODE BELOW */ - -let restaurantFinderApplication = { - applicationName: "Restaurant Finder", - applicationVersion: "1.0", - restaurants: restaurants, - findAvailableRestaurants: function (numberOfPeople) { - // Complete here - }, - findRestaurantServingDish: function (dishName) { - // Complete here - }, - countNumberOfRestaurantsInArea: function (area) { - // Complete here - } -}; - - /* DO NOT EDIT ANYTHING BELOW THIS LINE */ -let restaurantsAvailableFor5People = restaurantFinderApplication.findAvailableRestaurants(5); -console.log(`Find available restaurants for 5 people: Expected result: Ubiquitous Chip,Monkeyz, actual result: ${restaurantsAvailableFor5People}`); - -let restaurantsServingSalad = restaurantFinderApplication.findRestaurantServingDish("salad"); -console.log(`Find restaurants serving salad: Expected result: Paesano,Ubiquitous Chip, actual result: ${restaurantsServingSalad}`); - -let numberOfRestaurantsInCityCentre = restaurantFinderApplication.countNumberOfRestaurantsInArea("center"); -console.log(`Number of restaurants in city centre: Expected result: 2, actual result: ${numberOfRestaurantsInCityCentre}`); +let restaurantsAvailableFor5People = findAvailableRestaurants(restaurants, 5); +console.log( + `Find available restaurants for 5 people: Expected result: Ubiquitous Chip,Monkeyz, actual result: ${restaurantsAvailableFor5People}` +); + +let restaurantsServingSalad = findRestaurantServingDish(restaurants, "salad"); +console.log( + `Find restaurants serving salad: Expected result: Paesano,Ubiquitous Chip, actual result: ${restaurantsServingSalad}` +); + +let numberOfRestaurantsInCityCentre = countNumberOfRestaurantsInArea( + restaurants, + "center" +); +console.log( + `Number of restaurants in city centre: Expected result: 2, actual result: ${numberOfRestaurantsInCityCentre}` +); diff --git a/week-4/InClass/G-loop-through-objects/exercise1.js b/week-4/InClass/G-loop-through-objects/exercise1.js new file mode 100644 index 000000000..900a5f77c --- /dev/null +++ b/week-4/InClass/G-loop-through-objects/exercise1.js @@ -0,0 +1,13 @@ +// You are given an object of student names and grades +// Loop through all the students' grades and console log the name and grade of the ones with grade more than 18 +// Try to use both methods shown above to achieve this + +const studentGrades = { + tom: 20, + george: 17, + abdul: 19, +}; + +// Prints +// TOM - 20 +// ABDUL - 19 From d6bed7ce5293d5dd1d15a5fcbbde4d68e8d616c9 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 29 May 2020 23:11:37 +0100 Subject: [PATCH 18/37] update --- week-4/InClass/G-loop-through-objects/exercise1.js | 1 - 1 file changed, 1 deletion(-) diff --git a/week-4/InClass/G-loop-through-objects/exercise1.js b/week-4/InClass/G-loop-through-objects/exercise1.js index 900a5f77c..4eb6e30e6 100644 --- a/week-4/InClass/G-loop-through-objects/exercise1.js +++ b/week-4/InClass/G-loop-through-objects/exercise1.js @@ -1,6 +1,5 @@ // You are given an object of student names and grades // Loop through all the students' grades and console log the name and grade of the ones with grade more than 18 -// Try to use both methods shown above to achieve this const studentGrades = { tom: 20, From 2b0206a2987be295afc61dcbeec271f2d0f00f52 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Sat, 30 May 2020 11:39:40 +0100 Subject: [PATCH 19/37] add itworked file --- week-4/IT-WORKED.md | 0 .../G-loop-through-objects/exercise1.js | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 week-4/IT-WORKED.md diff --git a/week-4/IT-WORKED.md b/week-4/IT-WORKED.md new file mode 100644 index 000000000..e69de29bb diff --git a/week-4/InClass/G-loop-through-objects/exercise1.js b/week-4/InClass/G-loop-through-objects/exercise1.js index 4eb6e30e6..6eec1d838 100644 --- a/week-4/InClass/G-loop-through-objects/exercise1.js +++ b/week-4/InClass/G-loop-through-objects/exercise1.js @@ -1,12 +1,17 @@ -// You are given an object of student names and grades -// Loop through all the students' grades and console log the name and grade of the ones with grade more than 18 +let kitten1 = { + name: "Fluffy", + weeksOld: 2, +}; -const studentGrades = { - tom: 20, - george: 17, - abdul: 19, +let kitten2 = { + name: "Megatron", + weeksOld: 1, }; -// Prints -// TOM - 20 -// ABDUL - 19 +let kittens = [kitten1, kitten2]; + +function getName(kitten) { + return kitten.name.length === 5; +} + +kittens.map(getName); // should return ["Fluffy", "Megatron", "Billy"] From 7b33f98f73d075f5d2cd60a83bfe1c3851aa09ed Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 5 Jun 2020 20:32:24 +0100 Subject: [PATCH 20/37] move exercises for week5 --- .vscode/launch.json | 17 +++++++ week-4/Homework/mandatory/3-translator.js | 3 ++ .../InClass/E-arrays-of-objects/exercise-2.js | 47 ++++++++++++------ .../0-khanacademy/khanacademy.md | 0 .../{mandatory => extra}/1-study/study.md | 0 .../2-practice}/practice-codewars.md | 0 .../extra/{ => 3-extra}/extra-homework.md | 0 .../{2-exercises => 1-exercises}/exercises.js | 0 .../{2-exercises => 1-exercises}/index.html | 0 .../{2-exercises => 1-exercises}/style.css | 0 .../{3-project => 2-project}/README.md | 0 .../images/blue_clicked.png | Bin .../images/header-bike.jpg | Bin .../{3-project => 2-project}/index.html | 0 .../{3-project => 2-project}/js/main.js | 0 .../{3-project => 2-project}/styles/style.css | 0 week-5/WEEK5-WORKED.md | 0 17 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 .vscode/launch.json rename week-5/Homework/{mandatory => extra}/0-khanacademy/khanacademy.md (100%) rename week-5/Homework/{mandatory => extra}/1-study/study.md (100%) rename week-5/Homework/{mandatory/4-practice => extra/2-practice}/practice-codewars.md (100%) rename week-5/Homework/extra/{ => 3-extra}/extra-homework.md (100%) rename week-5/Homework/mandatory/{2-exercises => 1-exercises}/exercises.js (100%) rename week-5/Homework/mandatory/{2-exercises => 1-exercises}/index.html (100%) rename week-5/Homework/mandatory/{2-exercises => 1-exercises}/style.css (100%) rename week-5/Homework/mandatory/{3-project => 2-project}/README.md (100%) rename week-5/Homework/mandatory/{3-project => 2-project}/images/blue_clicked.png (100%) rename week-5/Homework/mandatory/{3-project => 2-project}/images/header-bike.jpg (100%) rename week-5/Homework/mandatory/{3-project => 2-project}/index.html (100%) rename week-5/Homework/mandatory/{3-project => 2-project}/js/main.js (100%) rename week-5/Homework/mandatory/{3-project => 2-project}/styles/style.css (100%) create mode 100644 week-5/WEEK5-WORKED.md diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..822e5d1e3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // 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": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${file}" + } + ] +} \ No newline at end of file diff --git a/week-4/Homework/mandatory/3-translator.js b/week-4/Homework/mandatory/3-translator.js index 33c6769dd..8cd13d915 100644 --- a/week-4/Homework/mandatory/3-translator.js +++ b/week-4/Homework/mandatory/3-translator.js @@ -18,6 +18,8 @@ const languages = { welsh: "Croeso", }; +console.log(languages.english); +console.log(languages["english"]); /* Write a 'greet' function that takes a parameter 'language' (always a string), and returns the greeting for that language - if it exists in your "languages" object. @@ -28,6 +30,7 @@ or in the event of an invalid input. function greet(language) { //write your code here + return languages[language]; } /* diff --git a/week-4/InClass/E-arrays-of-objects/exercise-2.js b/week-4/InClass/E-arrays-of-objects/exercise-2.js index 59c5c2ff8..665491667 100644 --- a/week-4/InClass/E-arrays-of-objects/exercise-2.js +++ b/week-4/InClass/E-arrays-of-objects/exercise-2.js @@ -32,25 +32,44 @@ let destination4 = { transportations: ["plane", "ferry"] }; -let travelDestinations = [destination1, destination2, destination3, destination4]; +let travelDestinations = [ + destination1, + destination2, + destination3, + destination4 +]; -/* -DO NOT EDIT ANYTHING ABOVE THIS LINE -WRITE YOUR CODE BELOW -*/ +// [ +// {destinationName: "Dublin", distanceKms: 350}, +// {destinationName: "Dublin", distanceKms: 350}, +// {destinationName: "Dublin", distanceKms: 350}, +// ] +// ["Dublin", "Paris", "Edinburgh"] -let destinationNamesWithin500Kms = // Complete here -let destinationNameReachableByFerry = // Complete here +// 1. Print in the console +// 2. all the destination names +// 3. more than 300 kms far away and reachable by train. -let destinationNamesMoreThan300KmsAwayByTrain = // Complete here (PRINT THE RESULT IN THE CONSOLE USING FOREACH) +function isReachable(destination) { + let isFar = destination.distanceKms > 300; + let trainReachable = destination.transportations.includes("train"); + return isFar && trainReachable; +} +let reachableDestinations = travelDestinations.filter(isReachable); -/* -DO NOT EDIT ANYTHING BELOW THIS LINE -*/ +function transformDestination(destination) { + let destinationName = destination.destinationName; + return destinationName; +} + +let destinationNames = reachableDestinations.map(transformDestination); + + +function printToConsole(destinationName) { + console.log(destinationName); +} -console.log(`Question 1) Expected result: Edinburgh,Dublin, actual result: ${destinationNamesWithin500Kms}`); -console.log(`Question 2) Expected result: Dublin, actual result: ${destinationNameReachableByFerry}`); -console.log(`Question 3) Expected result: London,Paris, actual result: ${destinationNamesMoreThan300KmsAwayByTrain}`); +destinationNames.forEach(printToConsole); diff --git a/week-5/Homework/mandatory/0-khanacademy/khanacademy.md b/week-5/Homework/extra/0-khanacademy/khanacademy.md similarity index 100% rename from week-5/Homework/mandatory/0-khanacademy/khanacademy.md rename to week-5/Homework/extra/0-khanacademy/khanacademy.md diff --git a/week-5/Homework/mandatory/1-study/study.md b/week-5/Homework/extra/1-study/study.md similarity index 100% rename from week-5/Homework/mandatory/1-study/study.md rename to week-5/Homework/extra/1-study/study.md diff --git a/week-5/Homework/mandatory/4-practice/practice-codewars.md b/week-5/Homework/extra/2-practice/practice-codewars.md similarity index 100% rename from week-5/Homework/mandatory/4-practice/practice-codewars.md rename to week-5/Homework/extra/2-practice/practice-codewars.md diff --git a/week-5/Homework/extra/extra-homework.md b/week-5/Homework/extra/3-extra/extra-homework.md similarity index 100% rename from week-5/Homework/extra/extra-homework.md rename to week-5/Homework/extra/3-extra/extra-homework.md diff --git a/week-5/Homework/mandatory/2-exercises/exercises.js b/week-5/Homework/mandatory/1-exercises/exercises.js similarity index 100% rename from week-5/Homework/mandatory/2-exercises/exercises.js rename to week-5/Homework/mandatory/1-exercises/exercises.js diff --git a/week-5/Homework/mandatory/2-exercises/index.html b/week-5/Homework/mandatory/1-exercises/index.html similarity index 100% rename from week-5/Homework/mandatory/2-exercises/index.html rename to week-5/Homework/mandatory/1-exercises/index.html diff --git a/week-5/Homework/mandatory/2-exercises/style.css b/week-5/Homework/mandatory/1-exercises/style.css similarity index 100% rename from week-5/Homework/mandatory/2-exercises/style.css rename to week-5/Homework/mandatory/1-exercises/style.css diff --git a/week-5/Homework/mandatory/3-project/README.md b/week-5/Homework/mandatory/2-project/README.md similarity index 100% rename from week-5/Homework/mandatory/3-project/README.md rename to week-5/Homework/mandatory/2-project/README.md diff --git a/week-5/Homework/mandatory/3-project/images/blue_clicked.png b/week-5/Homework/mandatory/2-project/images/blue_clicked.png similarity index 100% rename from week-5/Homework/mandatory/3-project/images/blue_clicked.png rename to week-5/Homework/mandatory/2-project/images/blue_clicked.png diff --git a/week-5/Homework/mandatory/3-project/images/header-bike.jpg b/week-5/Homework/mandatory/2-project/images/header-bike.jpg similarity index 100% rename from week-5/Homework/mandatory/3-project/images/header-bike.jpg rename to week-5/Homework/mandatory/2-project/images/header-bike.jpg diff --git a/week-5/Homework/mandatory/3-project/index.html b/week-5/Homework/mandatory/2-project/index.html similarity index 100% rename from week-5/Homework/mandatory/3-project/index.html rename to week-5/Homework/mandatory/2-project/index.html diff --git a/week-5/Homework/mandatory/3-project/js/main.js b/week-5/Homework/mandatory/2-project/js/main.js similarity index 100% rename from week-5/Homework/mandatory/3-project/js/main.js rename to week-5/Homework/mandatory/2-project/js/main.js diff --git a/week-5/Homework/mandatory/3-project/styles/style.css b/week-5/Homework/mandatory/2-project/styles/style.css similarity index 100% rename from week-5/Homework/mandatory/3-project/styles/style.css rename to week-5/Homework/mandatory/2-project/styles/style.css diff --git a/week-5/WEEK5-WORKED.md b/week-5/WEEK5-WORKED.md new file mode 100644 index 000000000..e69de29bb From ff90e30ba3568372005bf5ab3feb01673bbe0f96 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 5 Jun 2020 20:43:28 +0100 Subject: [PATCH 21/37] add images to exercise 1 homework --- .../1-exercises/assets/design_of_things.jpeg | Bin 0 -> 9120 bytes .../1-exercises/assets/most_human_human.jpeg | Bin 0 -> 5714 bytes .../assets/pragmatic_programmer.jpeg | Bin 0 -> 5727 bytes .../mandatory/1-exercises/exercises.js | 19 ++++++++++-------- 4 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 week-5/Homework/mandatory/1-exercises/assets/design_of_things.jpeg create mode 100644 week-5/Homework/mandatory/1-exercises/assets/most_human_human.jpeg create mode 100644 week-5/Homework/mandatory/1-exercises/assets/pragmatic_programmer.jpeg diff --git a/week-5/Homework/mandatory/1-exercises/assets/design_of_things.jpeg b/week-5/Homework/mandatory/1-exercises/assets/design_of_things.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..fdceb5cd15bbd8a9cb8cb8a22d8af95d1e1eba1c GIT binary patch literal 9120 zcmZ8{1yCGM(C@+F!NVbk26vakCD`HaBqTV&oj|Z8$l(y206E;rt z$p3q?#W~CzsGf{&;FZf^v*FXb)aJxqcMR-Pa8o-~3{ z08iHbKXX8IG>j*i0MU~*R5UaoCfbvg|LDma5gPFezUQ*qZ}H24Ic{phW`!!o8r1v*bY}%N62I&rSQ` zRQmEP=!e5>X_!;Mw%cXo{dp%yI_pSkO1dL;qe5+(T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Se)Fb=WV)>^PATwj~F?z-yHBcj`x>5A z?>5yF_(W!FS@_Z2b{$OBfvjGWAK3!99#)Ix57p?}RLoqn^=_e?Fxj@Qo9pKLA>uG; zVBdKPu>N|RpL;&~8Uyz~e*V8w@K5}6KjMNjvFSqT#X<)#2Z|>_VTLP9!-FoNk4%h2 zep-0hD*OfFFv#YvjKF^}3G8!Y-}lY^;2@af_C<}rq`O8}=ej8ebp_!Vt1HS^f{sFI z@;_o0IrxfwOD~fLr_~*fdLMasd~^E%nYmK1+p7E`@X5Uwt)bAKIf398pArvFZl4>G z`r*M%{=U3C*)q4jAitT?pS>Gw>M0JaDaC@D5vC2%9di@V?<^sYr*kDLcSs5qOI^U_ zr5}f_x=S}ug zVVuy^qNO1uqUB;lBLQFsH_u{LYUEnPW$Xgv<-Z z_)9ZpRjgLyYf_l$?)Bh2sclAs$5ot5{C2pj%rriu3+^Eya@upTgm?Oc6s9n}f&H5b zX1xP4J6%y+Ln{3@80f7P6aHV<^YT*4L30A^1|HZ_e4AIIR;OvO;B-lJ%b!g&*iMxV zjd!arG9_P60MiX_|ZR?_$n(=40e& zze6Wk-4ToS8m9oqj}zTFh(lhyMUAsJEV>u|iVBL=`s&3P$$|k>q=3)Ne!6#qc;e_=G_bnJfs DW(lHi literal 0 HcmV?d00001 diff --git a/week-5/Homework/mandatory/1-exercises/exercises.js b/week-5/Homework/mandatory/1-exercises/exercises.js index 174c5db04..fb837efcd 100644 --- a/week-5/Homework/mandatory/1-exercises/exercises.js +++ b/week-5/Homework/mandatory/1-exercises/exercises.js @@ -35,17 +35,20 @@ function exerciseTwo(shopping) { { title: "The Design of Everyday Things", author: "Don Norman", - alreadyRead: false + alreadyRead: false, + coverImageUrl: "assets/design_of_things.jpeg" }, { title: "The Most Human Human", author: "Brian Christian", - alreadyRead: true + alreadyRead: true, + coverImageUrl: "assets/most_human_human.jpeg" }, { title: "The Pragmatic Programmer", author: "Andrew Hunt", - alreadyRead: true + alreadyRead: true, + coverImageUrl: "assets/pragmatic_programmer.jpeg" } ]; @@ -74,7 +77,7 @@ function exerciseThree(books) { let people = [ { name: "Chris", job: "Teacher" }, { name: "Joanna", job: "Student" }, - { name: "Boris", job: "Prime Minister" } + { name: "Boris", job: "Prime Minister" }, ]; exerciseOne(people); @@ -87,18 +90,18 @@ const books = [ { title: "The Design of Everyday Things", author: "Don Norman", - alreadyRead: false + alreadyRead: false, }, { title: "The Most Human Human", author: "Brian Christian", - alreadyRead: true + alreadyRead: true, }, { title: "The Pragmatic Programmer", author: "Andrew Hunt", - alreadyRead: true - } + alreadyRead: true, + }, ]; exerciseThree(books); From fd49d01fbf0455444edce57eecd7f79e807974af Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 5 Jun 2020 21:44:41 +0100 Subject: [PATCH 22/37] add image links --- week-5/Homework/mandatory/1-exercises/exercises.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/week-5/Homework/mandatory/1-exercises/exercises.js b/week-5/Homework/mandatory/1-exercises/exercises.js index fb837efcd..09ed09252 100644 --- a/week-5/Homework/mandatory/1-exercises/exercises.js +++ b/week-5/Homework/mandatory/1-exercises/exercises.js @@ -24,7 +24,7 @@ function exerciseOne(arrayOfPeople) { * All of your HTML should go inside the Div tag with the id "content". * */ -function exerciseTwo(shopping) { +function exerciseTwo(shoppingItems) { //Write your code in here } @@ -91,16 +91,19 @@ const books = [ title: "The Design of Everyday Things", author: "Don Norman", alreadyRead: false, + coverImageUrl: "assets/design_of_things.jpeg", }, { title: "The Most Human Human", author: "Brian Christian", alreadyRead: true, + coverImageUrl: "assets/most_human_human.jpeg", }, { title: "The Pragmatic Programmer", author: "Andrew Hunt", alreadyRead: true, + coverImageUrl: "assets/pragmatic_programmer.jpeg", }, ]; From 53c9febf6122f5ce07fbf57dcafe4d9c89f4821d Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 5 Jun 2020 22:55:48 +0100 Subject: [PATCH 23/37] add task 6 --- week-5/InClass/A-dom-manipulation/exercise.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/week-5/InClass/A-dom-manipulation/exercise.js b/week-5/InClass/A-dom-manipulation/exercise.js index bb4f2e92b..717fb16f5 100644 --- a/week-5/InClass/A-dom-manipulation/exercise.js +++ b/week-5/InClass/A-dom-manipulation/exercise.js @@ -16,7 +16,6 @@ Write JavaScript below that logs: */ - /* Task 2 ====== @@ -24,7 +23,6 @@ Task 2 When a user clicks the 'ALERT' button, an alert box should pop up with the text "Thanks for visiting Bikes for Refugees!" */ - /* Task 3 ======= @@ -32,7 +30,6 @@ Task 3 Write JavaScript below that changes the background colour of the page when the 'Change colour' button is clicked. */ - /* Task 4 ====== @@ -40,11 +37,17 @@ Task 4 When a user clicks the 'Add some text' button, a new paragraph should be added below the buttons that says "Read more below." */ - - /* Task 5 ====== When the 'Larger links!' button is clicked, the text of all links on the page should increase. -*/ \ No newline at end of file +*/ + +/* +Task 6 +====== + +Using JavaScript, create an unordered list under the "Add" button. +When the "Add" button is pressed, get the value of the text box on its left, and add it to the list you created above. +*/ From b1add696dddab895d6f71df32ea5261e01e6c49c Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Sat, 6 Jun 2020 10:08:28 +0100 Subject: [PATCH 24/37] move khanacademy back into mandatory --- .../3-learning-khanacademy}/khanacademy.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename week-5/Homework/{extra/0-khanacademy => mandatory/3-learning-khanacademy}/khanacademy.md (100%) diff --git a/week-5/Homework/extra/0-khanacademy/khanacademy.md b/week-5/Homework/mandatory/3-learning-khanacademy/khanacademy.md similarity index 100% rename from week-5/Homework/extra/0-khanacademy/khanacademy.md rename to week-5/Homework/mandatory/3-learning-khanacademy/khanacademy.md From b4eb201ea01b40ccafbfbe4544912160ddf4885f Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Tue, 9 Jun 2020 22:58:36 +0100 Subject: [PATCH 25/37] restructure week6 --- week-5/Homework/mandatory/2-project/README.md | 2 +- .../example-screenshots/example-level1.png | Bin .../example-screenshots/example-level2.png | Bin .../3-slideshow => extra/2-slideshow}/index.html | 0 .../2-slideshow}/slideshow.js | 0 .../3-slideshow => extra/2-slideshow}/style.css | 0 .../3-slideshow => extra/2-slideshow}/task.md | 0 .../task.md | 0 .../mandatory/3-DOM-practice}/ada-lovelace.jpg | Bin .../mandatory/3-DOM-practice}/finished-page.jpg | Bin .../mandatory/3-DOM-practice}/grace-hopper.jpg | Bin .../mandatory/3-DOM-practice}/index.html | 0 .../3-DOM-practice}/katherine-johnson.jpg | Bin .../mandatory/3-DOM-practice}/main.js | 0 .../mandatory/3-DOM-practice}/styles.css | 0 week-6/InClass/1-Async/exercise1.js | 14 ++++++++++++++ .../exercise-1/exercise.js | 0 .../exercise-1/index.html | 0 .../exercise-2/exercise.js | 0 .../exercise-2/index.html | 0 week-6/WEEK6-WORKED.md | 0 21 files changed, 15 insertions(+), 1 deletion(-) rename week-6/Homework/{mandatory/3-slideshow => extra/2-slideshow}/example-screenshots/example-level1.png (100%) rename week-6/Homework/{mandatory/3-slideshow => extra/2-slideshow}/example-screenshots/example-level2.png (100%) rename week-6/Homework/{mandatory/3-slideshow => extra/2-slideshow}/index.html (100%) rename week-6/Homework/{mandatory/3-slideshow => extra/2-slideshow}/slideshow.js (100%) rename week-6/Homework/{mandatory/3-slideshow => extra/2-slideshow}/style.css (100%) rename week-6/Homework/{mandatory/3-slideshow => extra/2-slideshow}/task.md (100%) rename week-6/Homework/extra/{2-slideshow-extra => 3-slideshow-extra}/task.md (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/ada-lovelace.jpg (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/finished-page.jpg (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/grace-hopper.jpg (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/index.html (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/katherine-johnson.jpg (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/main.js (100%) rename week-6/{InClass/DOM-practice => Homework/mandatory/3-DOM-practice}/styles.css (100%) create mode 100644 week-6/InClass/1-Async/exercise1.js rename week-6/InClass/{Callbacks => 2-Callbacks}/exercise-1/exercise.js (100%) rename week-6/InClass/{Callbacks => 2-Callbacks}/exercise-1/index.html (100%) rename week-6/InClass/{Callbacks => 2-Callbacks}/exercise-2/exercise.js (100%) rename week-6/InClass/{Callbacks => 2-Callbacks}/exercise-2/index.html (100%) create mode 100644 week-6/WEEK6-WORKED.md diff --git a/week-5/Homework/mandatory/2-project/README.md b/week-5/Homework/mandatory/2-project/README.md index 5caa8a338..f1cf9ec91 100644 --- a/week-5/Homework/mandatory/2-project/README.md +++ b/week-5/Homework/mandatory/2-project/README.md @@ -28,7 +28,7 @@ Here's an example of how the website should look for the blue button: ![Blue button example](images/blue_clicked.png) -## Part 2 +## Part 2 - VERY BONUS BONUS Just below the buttons, there's a form called **Register with us**. diff --git a/week-6/Homework/mandatory/3-slideshow/example-screenshots/example-level1.png b/week-6/Homework/extra/2-slideshow/example-screenshots/example-level1.png similarity index 100% rename from week-6/Homework/mandatory/3-slideshow/example-screenshots/example-level1.png rename to week-6/Homework/extra/2-slideshow/example-screenshots/example-level1.png diff --git a/week-6/Homework/mandatory/3-slideshow/example-screenshots/example-level2.png b/week-6/Homework/extra/2-slideshow/example-screenshots/example-level2.png similarity index 100% rename from week-6/Homework/mandatory/3-slideshow/example-screenshots/example-level2.png rename to week-6/Homework/extra/2-slideshow/example-screenshots/example-level2.png diff --git a/week-6/Homework/mandatory/3-slideshow/index.html b/week-6/Homework/extra/2-slideshow/index.html similarity index 100% rename from week-6/Homework/mandatory/3-slideshow/index.html rename to week-6/Homework/extra/2-slideshow/index.html diff --git a/week-6/Homework/mandatory/3-slideshow/slideshow.js b/week-6/Homework/extra/2-slideshow/slideshow.js similarity index 100% rename from week-6/Homework/mandatory/3-slideshow/slideshow.js rename to week-6/Homework/extra/2-slideshow/slideshow.js diff --git a/week-6/Homework/mandatory/3-slideshow/style.css b/week-6/Homework/extra/2-slideshow/style.css similarity index 100% rename from week-6/Homework/mandatory/3-slideshow/style.css rename to week-6/Homework/extra/2-slideshow/style.css diff --git a/week-6/Homework/mandatory/3-slideshow/task.md b/week-6/Homework/extra/2-slideshow/task.md similarity index 100% rename from week-6/Homework/mandatory/3-slideshow/task.md rename to week-6/Homework/extra/2-slideshow/task.md diff --git a/week-6/Homework/extra/2-slideshow-extra/task.md b/week-6/Homework/extra/3-slideshow-extra/task.md similarity index 100% rename from week-6/Homework/extra/2-slideshow-extra/task.md rename to week-6/Homework/extra/3-slideshow-extra/task.md diff --git a/week-6/InClass/DOM-practice/ada-lovelace.jpg b/week-6/Homework/mandatory/3-DOM-practice/ada-lovelace.jpg similarity index 100% rename from week-6/InClass/DOM-practice/ada-lovelace.jpg rename to week-6/Homework/mandatory/3-DOM-practice/ada-lovelace.jpg diff --git a/week-6/InClass/DOM-practice/finished-page.jpg b/week-6/Homework/mandatory/3-DOM-practice/finished-page.jpg similarity index 100% rename from week-6/InClass/DOM-practice/finished-page.jpg rename to week-6/Homework/mandatory/3-DOM-practice/finished-page.jpg diff --git a/week-6/InClass/DOM-practice/grace-hopper.jpg b/week-6/Homework/mandatory/3-DOM-practice/grace-hopper.jpg similarity index 100% rename from week-6/InClass/DOM-practice/grace-hopper.jpg rename to week-6/Homework/mandatory/3-DOM-practice/grace-hopper.jpg diff --git a/week-6/InClass/DOM-practice/index.html b/week-6/Homework/mandatory/3-DOM-practice/index.html similarity index 100% rename from week-6/InClass/DOM-practice/index.html rename to week-6/Homework/mandatory/3-DOM-practice/index.html diff --git a/week-6/InClass/DOM-practice/katherine-johnson.jpg b/week-6/Homework/mandatory/3-DOM-practice/katherine-johnson.jpg similarity index 100% rename from week-6/InClass/DOM-practice/katherine-johnson.jpg rename to week-6/Homework/mandatory/3-DOM-practice/katherine-johnson.jpg diff --git a/week-6/InClass/DOM-practice/main.js b/week-6/Homework/mandatory/3-DOM-practice/main.js similarity index 100% rename from week-6/InClass/DOM-practice/main.js rename to week-6/Homework/mandatory/3-DOM-practice/main.js diff --git a/week-6/InClass/DOM-practice/styles.css b/week-6/Homework/mandatory/3-DOM-practice/styles.css similarity index 100% rename from week-6/InClass/DOM-practice/styles.css rename to week-6/Homework/mandatory/3-DOM-practice/styles.css diff --git a/week-6/InClass/1-Async/exercise1.js b/week-6/InClass/1-Async/exercise1.js new file mode 100644 index 000000000..be32aad86 --- /dev/null +++ b/week-6/InClass/1-Async/exercise1.js @@ -0,0 +1,14 @@ +const greekGods = [ + "Aphrodite", + "Ares", + "Artemis", + "Athena", + "Poseidon", + "Zeus", +]; + +// before running the code in your browser, discuss the expected order of each loop + +// synchronous - loop through the array of greek gods and print the index numbers and values to the console, e.g. '1. Ares' + +// asynchronous - same as before but the index and the value of the god at position 2 in array should be printed after 2 seconds. Use: setTimeout() diff --git a/week-6/InClass/Callbacks/exercise-1/exercise.js b/week-6/InClass/2-Callbacks/exercise-1/exercise.js similarity index 100% rename from week-6/InClass/Callbacks/exercise-1/exercise.js rename to week-6/InClass/2-Callbacks/exercise-1/exercise.js diff --git a/week-6/InClass/Callbacks/exercise-1/index.html b/week-6/InClass/2-Callbacks/exercise-1/index.html similarity index 100% rename from week-6/InClass/Callbacks/exercise-1/index.html rename to week-6/InClass/2-Callbacks/exercise-1/index.html diff --git a/week-6/InClass/Callbacks/exercise-2/exercise.js b/week-6/InClass/2-Callbacks/exercise-2/exercise.js similarity index 100% rename from week-6/InClass/Callbacks/exercise-2/exercise.js rename to week-6/InClass/2-Callbacks/exercise-2/exercise.js diff --git a/week-6/InClass/Callbacks/exercise-2/index.html b/week-6/InClass/2-Callbacks/exercise-2/index.html similarity index 100% rename from week-6/InClass/Callbacks/exercise-2/index.html rename to week-6/InClass/2-Callbacks/exercise-2/index.html diff --git a/week-6/WEEK6-WORKED.md b/week-6/WEEK6-WORKED.md new file mode 100644 index 000000000..e69de29bb From 3e32b890e9bb5e40bc9164b85d3592f12cf79c42 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 12 Jun 2020 21:26:25 +0100 Subject: [PATCH 26/37] simplify exercise 1 --- week-6/InClass/1-Async/exercise1.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/week-6/InClass/1-Async/exercise1.js b/week-6/InClass/1-Async/exercise1.js index be32aad86..5c0134468 100644 --- a/week-6/InClass/1-Async/exercise1.js +++ b/week-6/InClass/1-Async/exercise1.js @@ -7,8 +7,5 @@ const greekGods = [ "Zeus", ]; -// before running the code in your browser, discuss the expected order of each loop - -// synchronous - loop through the array of greek gods and print the index numbers and values to the console, e.g. '1. Ares' - -// asynchronous - same as before but the index and the value of the god at position 2 in array should be printed after 2 seconds. Use: setTimeout() +// 1. Console.log() the name of the first and second god in the list +// 2. Console.log() the name of the first god after 3 seconds, and the name of the second god after 1 second \ No newline at end of file From 72e3e21fea6850bfc1b1903c5a45e6a5aed0ddca Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 12 Jun 2020 22:49:39 +0100 Subject: [PATCH 27/37] simplify dom exercise --- .../2-Callbacks/exercise-1/exercise.js | 3 +- .../2-Callbacks/exercise-2/exercise.js | 77 ++++++++----------- .../InClass/2-Callbacks/exercise-2/index.html | 52 +++++++------ 3 files changed, 62 insertions(+), 70 deletions(-) diff --git a/week-6/InClass/2-Callbacks/exercise-1/exercise.js b/week-6/InClass/2-Callbacks/exercise-1/exercise.js index 40f06b026..02fc93607 100644 --- a/week-6/InClass/2-Callbacks/exercise-1/exercise.js +++ b/week-6/InClass/2-Callbacks/exercise-1/exercise.js @@ -6,8 +6,7 @@ Task 1 Using setTimeout, change the background colour of the page after 5 seconds (5000 milliseconds). Task 2 -Update your code to make the colour change every 5 seconds to something different. Hint: try searching for setInterval. Complete the exercises in this CodePen +Update your code to make the colour change every 5 seconds to something different. Hint: try searching for setInterval. -Prefer to work on a codepen? https://codepen.io/makanti/pen/abOreLg ================ */ \ No newline at end of file diff --git a/week-6/InClass/2-Callbacks/exercise-2/exercise.js b/week-6/InClass/2-Callbacks/exercise-2/exercise.js index eca95957d..d7e93d7eb 100644 --- a/week-6/InClass/2-Callbacks/exercise-2/exercise.js +++ b/week-6/InClass/2-Callbacks/exercise-2/exercise.js @@ -2,69 +2,56 @@ ================ Exercise 2 ---------- -You are given the following list of movies - -Task 1 -Create a function called "showMovies" that -- iterates through the "movies" array and -- for each movie, it creates a

element with the movie title and director and append it to the #all-movies div. -- it sets the innerText of the #movies-number element to the total number of the movies in the array "movies" - -Task 2 -Amend your function above to only show movies after 1 second. Remember to use setTimeout to achieve that -Create a new function called "addMovie" -- it receives a movie object as an argument - your can create a new object for your favorite movie following using the "myMovies" objects as a guide -- it adds the new movie to the list of movies after 2 seconds. Remember to setTimeout to achieve that -Call addMovies to add the new movie to the list and then showMovies to see the movies added on the screen. -How many movies can you see on your page? - -Task 3 -Can you make sure the new movie you just added is showing on the screen? -TIP: use callbacks - -Task 4 - **Extra** -Create a form anywhere on your page. The form should have -- 4 input text fields, one for each property of your movie object -- a "save" button. -When the button is clicked -- The field values should be used to create a new movie object literal -- The new movie is then added to the list of movies and gets displayed on your page -TIP: Use the functions you created on tasks 1-3 - -Prefer to work on a codepen? https://codepen.io/makanti/pen/MWwMgmW?editors ================ */ const movies = [ { title: "Color Out of Space", - director: "Richard Stanley", - type: "sci-fi", haveWatched: true, }, { title: "A Twelve-Year Night", - director: "Álvaro Brechner", - type: "horror", haveWatched: false, }, { title: "The Whistlers", - director: "Corneliu Porumboiu", - type: "comedy", haveWatched: true, }, { title: "The Invisible Man", - director: "Leigh Whannell", - type: "horror", haveWatched: false, }, ]; -// create showMovies function - - -// create a new movie object for your favorite movie - - -// create addMovies function +function createDomMovie(movie) { + const movieInfo = document.createElement("p"); + movieInfo.innerText = `Title: ${movie.title}, director ${movie.director}`; + const allMovies = document.querySelector("#all-movies"); + allMovies.appendChild(movieInfo); +} + +function reloadMovieList() { + const allMovies = document.querySelector("#all-movies"); + allMovies.innerHTML = ""; + movies.forEach(createDomMovie); +} + +reloadMovieList(); + +function addMovie() { + const loadingText = document.querySelector(""); + const movieTitleInput = document.querySelector("#new-movie-input"); + const movieTitle = movieTitleInput.value; + + // Your task - write the code in this function: + // 1. The moment this function is called: + // - clear the input so it's empty + // - show the loading text + // 2. after 2 seconds: + // - create a new movie object and add it to the "movies" array + // - hide the "loading text" + // - make sure the new movie shows up in the movie list +} + +const addMovieButton = document.querySelector("#add-movie-btn"); +addMovieButton.addEventListener("click", addMovie); diff --git a/week-6/InClass/2-Callbacks/exercise-2/index.html b/week-6/InClass/2-Callbacks/exercise-2/index.html index bc9654c0b..bdace1a22 100644 --- a/week-6/InClass/2-Callbacks/exercise-2/index.html +++ b/week-6/InClass/2-Callbacks/exercise-2/index.html @@ -1,29 +1,35 @@ - + + + + CodeYourFuture - Callbacks + + + + + - - - CodeYourFuture - Callbacks - - - - - - - -

-
-

My movies

-
-

Number of movies:

+ +
+
+

My movies

+
+

+ Saving your new movie... +

+ + + - - - \ No newline at end of file + + From 5283e47cc1842b020c159e6f5443e12b7c96cc05 Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 12 Jun 2020 22:51:12 +0100 Subject: [PATCH 28/37] hide movie loader --- week-6/InClass/2-Callbacks/exercise-2/index.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/week-6/InClass/2-Callbacks/exercise-2/index.html b/week-6/InClass/2-Callbacks/exercise-2/index.html index bdace1a22..383feb396 100644 --- a/week-6/InClass/2-Callbacks/exercise-2/index.html +++ b/week-6/InClass/2-Callbacks/exercise-2/index.html @@ -14,6 +14,14 @@ body { padding: 30px; } + + .hide { + display: none; + } + + .show { + display: block; + } @@ -22,7 +30,7 @@

My movies

-

+

Saving your new movie...

From c0c8b8b49fa548485c16bd72cd118ed3d6ecc2be Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 12 Jun 2020 23:01:13 +0100 Subject: [PATCH 29/37] add more exercise details --- week-6/InClass/2-Callbacks/exercise-2/exercise.js | 10 +++++----- week-6/InClass/2-Callbacks/exercise-2/index.html | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/week-6/InClass/2-Callbacks/exercise-2/exercise.js b/week-6/InClass/2-Callbacks/exercise-2/exercise.js index d7e93d7eb..c1596fa1f 100644 --- a/week-6/InClass/2-Callbacks/exercise-2/exercise.js +++ b/week-6/InClass/2-Callbacks/exercise-2/exercise.js @@ -25,7 +25,7 @@ const movies = [ function createDomMovie(movie) { const movieInfo = document.createElement("p"); - movieInfo.innerText = `Title: ${movie.title}, director ${movie.director}`; + movieInfo.innerText = `Title: ${movie.title}. Seen: ${movie.haveWatched}`; const allMovies = document.querySelector("#all-movies"); allMovies.appendChild(movieInfo); } @@ -39,16 +39,16 @@ function reloadMovieList() { reloadMovieList(); function addMovie() { - const loadingText = document.querySelector(""); + const loadingText = document.querySelector("#loading-text"); const movieTitleInput = document.querySelector("#new-movie-input"); const movieTitle = movieTitleInput.value; // Your task - write the code in this function: // 1. The moment this function is called: // - clear the input so it's empty - // - show the loading text - // 2. after 2 seconds: - // - create a new movie object and add it to the "movies" array + // - show the loading text (Hint: look inside index.html for some CSS classes you can use to show and hide this element) + // 2. after 4 seconds: + // - create a new movie object and add it to the "movies" array (make sure its "haveWatched" value is false) // - hide the "loading text" // - make sure the new movie shows up in the movie list } diff --git a/week-6/InClass/2-Callbacks/exercise-2/index.html b/week-6/InClass/2-Callbacks/exercise-2/index.html index 383feb396..178eced62 100644 --- a/week-6/InClass/2-Callbacks/exercise-2/index.html +++ b/week-6/InClass/2-Callbacks/exercise-2/index.html @@ -22,6 +22,13 @@ .show { display: block; } + + #loading-text { + background: lightblue; + width: 200px; + padding: 5px; + border-radius: 10px; + } From d8d5674dfc255c5511212fc64fab361f9d355e8b Mon Sep 17 00:00:00 2001 From: r-darby Date: Sat, 27 Jun 2020 06:22:23 +0100 Subject: [PATCH 30/37] Week-7 add InClass Exercises --- week-7/InClass/1-Errors/exercise1.js | 17 + week-7/InClass/1-Errors/exercise2.js | 10 + week-7/InClass/1-Errors/exercise3.js | 8 + week-7/InClass/1-Errors/exercise4.js | 10 + week-7/InClass/1-Errors/exercise5.js | 19 ++ week-7/InClass/2-Debugging/exercise1.js | 16 + week-7/InClass/2-Debugging/exercise2.js | 16 + week-7/InClass/2-Debugging/exercise3.js | 24 ++ week-7/InClass/2-Debugging/exercise4.js | 20 ++ week-7/InClass/2-Debugging/exercise5.js | 20 ++ week-7/InClass/2-Debugging/exercise6.js | 11 + .../3-Debugging-Library-Code/.gitattributes | 2 + .../3-Debugging-Library-Code/README.md | 16 + .../3-Debugging-Library-Code/index.html | 82 +++++ .../InClass/3-Debugging-Library-Code/main.js | 170 ++++++++++ .../3-Debugging-Library-Code/styles/main.css | 308 ++++++++++++++++++ .../3-Debugging-Library-Code/styles/reset.css | 129 ++++++++ 17 files changed, 878 insertions(+) create mode 100644 week-7/InClass/1-Errors/exercise1.js create mode 100644 week-7/InClass/1-Errors/exercise2.js create mode 100644 week-7/InClass/1-Errors/exercise3.js create mode 100644 week-7/InClass/1-Errors/exercise4.js create mode 100644 week-7/InClass/1-Errors/exercise5.js create mode 100644 week-7/InClass/2-Debugging/exercise1.js create mode 100644 week-7/InClass/2-Debugging/exercise2.js create mode 100644 week-7/InClass/2-Debugging/exercise3.js create mode 100644 week-7/InClass/2-Debugging/exercise4.js create mode 100644 week-7/InClass/2-Debugging/exercise5.js create mode 100644 week-7/InClass/2-Debugging/exercise6.js create mode 100644 week-7/InClass/3-Debugging-Library-Code/.gitattributes create mode 100644 week-7/InClass/3-Debugging-Library-Code/README.md create mode 100644 week-7/InClass/3-Debugging-Library-Code/index.html create mode 100644 week-7/InClass/3-Debugging-Library-Code/main.js create mode 100644 week-7/InClass/3-Debugging-Library-Code/styles/main.css create mode 100644 week-7/InClass/3-Debugging-Library-Code/styles/reset.css diff --git a/week-7/InClass/1-Errors/exercise1.js b/week-7/InClass/1-Errors/exercise1.js new file mode 100644 index 000000000..be0c54586 --- /dev/null +++ b/week-7/InClass/1-Errors/exercise1.js @@ -0,0 +1,17 @@ +/* Remember to look at the error message, identify the +type of error, and see which line the error is on + +You don't need to fix this error, just explain WHY it +is happening */ + +let myName = "Reshma"; + +myName = myName.toUpperCase(); + +console.log(myName); + +let myAge = 44; + +myAge = myAge.toUpperCase(); + +console.log(myAge); \ No newline at end of file diff --git a/week-7/InClass/1-Errors/exercise2.js b/week-7/InClass/1-Errors/exercise2.js new file mode 100644 index 000000000..f6bb295ad --- /dev/null +++ b/week-7/InClass/1-Errors/exercise2.js @@ -0,0 +1,10 @@ +/* Remember to look at the error message, identify the +type of error, and see which line the error is on + +Then please fix the error! */ + +let myAge = 25; + +if myAge > 18 { + console.log("Yes can vote"); +} \ No newline at end of file diff --git a/week-7/InClass/1-Errors/exercise3.js b/week-7/InClass/1-Errors/exercise3.js new file mode 100644 index 000000000..9aa38d41d --- /dev/null +++ b/week-7/InClass/1-Errors/exercise3.js @@ -0,0 +1,8 @@ +/* Remember to look at the error message, identify the +type of error, and see which line the error is on + +Then please fix the error! */ + +// let greeting = "Hello"; + +console.log(greeting); \ No newline at end of file diff --git a/week-7/InClass/1-Errors/exercise4.js b/week-7/InClass/1-Errors/exercise4.js new file mode 100644 index 000000000..2da79db59 --- /dev/null +++ b/week-7/InClass/1-Errors/exercise4.js @@ -0,0 +1,10 @@ +/* Remember to look at the error message, identify the +type of error, and see which line the error is on + +Then please fix the error! */ + +let ages; // = [4, 28, 55, 15]; + +let a = ages.length; + +console.log(a); \ No newline at end of file diff --git a/week-7/InClass/1-Errors/exercise5.js b/week-7/InClass/1-Errors/exercise5.js new file mode 100644 index 000000000..3d8188f79 --- /dev/null +++ b/week-7/InClass/1-Errors/exercise5.js @@ -0,0 +1,19 @@ +/* Remember to look at the error message, identify the +type of error, and see which line the error is on + +Then please fix the error! */ + +function calculateAgeInMonths(ages){ + let newArray = ages.map(multiplyBy12); + return newArray; +} + +function multiplyBy12(age){ + return age * 12; +} + +let peopleAges = [4, 28, 55, 15]; + +let agesInMonths = calculateAgeInMonths(); + +console.log(agesInMonths); \ No newline at end of file diff --git a/week-7/InClass/2-Debugging/exercise1.js b/week-7/InClass/2-Debugging/exercise1.js new file mode 100644 index 000000000..b510977b2 --- /dev/null +++ b/week-7/InClass/2-Debugging/exercise1.js @@ -0,0 +1,16 @@ +/* +Run this code and see if there is a problem with the +output. + +Why is the bug happening? How do we fix it? +*/ + +function capitaliseName(name){ + return name.toUpperCase(); +} + +let myName = "santanu"; + +capitaliseName(myName); + +console.log(myName); \ No newline at end of file diff --git a/week-7/InClass/2-Debugging/exercise2.js b/week-7/InClass/2-Debugging/exercise2.js new file mode 100644 index 000000000..21ee6d171 --- /dev/null +++ b/week-7/InClass/2-Debugging/exercise2.js @@ -0,0 +1,16 @@ +/* +Run this code and see if there is a problem with the +output. + +Why is the bug happening? How do we fix it? +*/ + +function greet(firstName, lastName){ + console.log("Hello " + firstName + " " + lastName); +} + +let myFirstName = "Safra"; + +let mySurname = "Catz"; + +greet(myFirstName); \ No newline at end of file diff --git a/week-7/InClass/2-Debugging/exercise3.js b/week-7/InClass/2-Debugging/exercise3.js new file mode 100644 index 000000000..65f558e3a --- /dev/null +++ b/week-7/InClass/2-Debugging/exercise3.js @@ -0,0 +1,24 @@ +/* +We want our code to show the ages which are 17 or greater + +Run this code and see if there is a problem with the +output. + +Why is the bug happening? How do we fix it? +*/ + +function canDrive(a){ + if(a <= 17){ + return true; + }else{ + return false; + } +} + +const ages = [22, 15, 29, 31, 7, 54, 13]; + +const legalDrivers = ages.filter(canDrive); + +console.log(legalDrivers); + +// We'd better fix this bug or our company will be sending out provisional driving licences to children! \ No newline at end of file diff --git a/week-7/InClass/2-Debugging/exercise4.js b/week-7/InClass/2-Debugging/exercise4.js new file mode 100644 index 000000000..fa703b3e6 --- /dev/null +++ b/week-7/InClass/2-Debugging/exercise4.js @@ -0,0 +1,20 @@ +/* +We were expecting the messyNames array to contain only Strings, +but it doesn't! + +First, can you understand why we get an error? What kind of error is it? + +Second - we asked the Business Analyst, and she told us if an element +is not a String, we should return the String "NO VALUE" - please +modify the code to do this +*/ + +function capitalise(customer){ + return customer.toUpperCase(); +} + +const messyNames = ["Sundar", "reshma", true, "Maria", "Shantanu", 5 ]; + +const customers = messyNames.map(capitalise); + +console.log(customers); \ No newline at end of file diff --git a/week-7/InClass/2-Debugging/exercise5.js b/week-7/InClass/2-Debugging/exercise5.js new file mode 100644 index 000000000..7a3dfc8f5 --- /dev/null +++ b/week-7/InClass/2-Debugging/exercise5.js @@ -0,0 +1,20 @@ +/* +We want to print the ages only of people who can vote + +But our code prints out all the ages! + +How can we change line 20 so we only print ages of people who can vote? +*/ + +function canVote(age){ + if(age >= 18){ + return true; + }else{ + return false; + } +} +const ages = [17, 26, 4, 18, 7, 12, 31]; + +let voterAges = ages.filter(canVote); + +console.log(ages); \ No newline at end of file diff --git a/week-7/InClass/2-Debugging/exercise6.js b/week-7/InClass/2-Debugging/exercise6.js new file mode 100644 index 000000000..da3b02932 --- /dev/null +++ b/week-7/InClass/2-Debugging/exercise6.js @@ -0,0 +1,11 @@ +/* +Run this code and see if the result is what you expect + +What is the problem, and can you fix it? +*/ + +let myName = "Sundar"; + +if (myName = "Reshma" ){ + console.log("Hello"); +} \ No newline at end of file diff --git a/week-7/InClass/3-Debugging-Library-Code/.gitattributes b/week-7/InClass/3-Debugging-Library-Code/.gitattributes new file mode 100644 index 000000000..dfe077042 --- /dev/null +++ b/week-7/InClass/3-Debugging-Library-Code/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/week-7/InClass/3-Debugging-Library-Code/README.md b/week-7/InClass/3-Debugging-Library-Code/README.md new file mode 100644 index 000000000..f057f51ac --- /dev/null +++ b/week-7/InClass/3-Debugging-Library-Code/README.md @@ -0,0 +1,16 @@ +# Debugging My Book Library + +My website should be able to: + +- View a list of books that I've read +- Add books to a list of books that I've read + - Including title, author, number of pages and if I've read it + - If any of the information is missing it shouldn't add the book and should show an alert +- Remove books from my list + +## Task + +This purposefully broken website should use the tools we talked about in the lesson. + +You can find a working version of this here: +https://arodrigues92.github.io/library/ diff --git a/week-7/InClass/3-Debugging-Library-Code/index.html b/week-7/InClass/3-Debugging-Library-Code/index.html new file mode 100644 index 000000000..3ab2800bd --- /dev/null +++ b/week-7/InClass/3-Debugging-Library-Code/index.html @@ -0,0 +1,82 @@ + + + + + + Odin's Library + + + + + + + + +
+

Odin's Library

+
+
+ +
+
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + +
TitleAuthorPagesRead
+
+
+ +
+
+ + + diff --git a/week-7/InClass/3-Debugging-Library-Code/main.js b/week-7/InClass/3-Debugging-Library-Code/main.js new file mode 100644 index 000000000..02ff2faec --- /dev/null +++ b/week-7/InClass/3-Debugging-Library-Code/main.js @@ -0,0 +1,170 @@ +const addButtons = document.querySelectorAll(".add-button"); +const formContainer = document.getElementById("form-container"); +const tableBody = document.getElementById("table-body"); +const submitted = document.getElementById("submitted"); + +let bookNumber = 0; +let myLibrary = []; + +const book1 = { + title: "Crime and punishment", + author: "Fyodor Dostoyevksy", + page: 671, + read: "Yes", +}; +const book2 = { + title: "A brief history of time", + author: "Stephen Hawking", + page: 212, + read: "No", +}; + +myLibrary.push(book1; +myLibrary.push(book2); + +render(); + +addButtons.forEach((button) => { + button.addEventListener("click", () => { + formContainer.style.display = "block"; + }); +}; + +function addDeleteButtons() { + let deleteButtons = document.querySelectorAll(".delete"); + + deleteButtons.forEach((button) => { + if (button.getAttribute("data-book") == bookNumber) { + //Only add eventListeners to new books + button.addEventListener("clicksss", () => { + deleteBook(button.getAttribute("data-book")); + }); + } + }); +} + +function addReadButtons() { + let readButtons = document.querySelectorAll(".change-read"); + + readButtons.forEach((button) => { + if (button.getAttribute("data-book") == bookNumber) { + button.addEventListener("click", () => { + changeReadStatus(button.getAttribute("data-book"), button); + }); + } + }); +} + +function deleteBook(number) { + let toDelete = document.querySelector(`tr[data-book="${number}"]`); + toDelete.remove(); +} + +function changeReadStatus(number, button) { + if (myLibrary[number]["read"] === "Yes") { + myLibrary[number]["read"] = "No"; + button.innerText = "No"; + button.classList.remove("button-green"); + button.classList.add("button-red"); + } else { + myLibrary[number]["read"] = "Yes"; + button.innerText = "Yes"; + button.classList.remove("button-red"); + button.classList.add("button-green"); + } +} + +function addBookToLibrary(title, author, pages, read) { + let book = { title: title, author: author, page: pages, read: read }; + myLibrary.push(book); +} + +function render() { + for (let i = 0; i < myLibrary.length; i++) { + if (i === bookNumber) { + let row = document.createElement("tr"); + + if (bookNumber % 2 !== 0) { + //Adds color to every other row + row.classList.add("color-row"); + } + + row.setAttribute("data-book", bookNumber); + + let titleCell = document.createElement("td"); + titleCell.append(myLibrary[i].title); + row.append(titleCella); + + let authorCell = document.createElement("td"); + authorCell.append(myLibrary[i].author); + row.append(authorCell); + + let pageCell = document.createElement("td"); + pageCell.append(myLibrary[i].page); + row.append(pageCell); + + let readCell = document.createElement("td"); + let button = document.createElement("button"); + button.innerText = myLibrary[i].read; + + if (myLibrary[i].read === "Yes") { + button.classList.add("button-green"); + } else { + button.classList.add("button-red"); + } + + button.classList.add("change-read"); + button.setAttribute("type", "button"); + button.setAttribute("data-book", bookNumber); + readCell.append(button); + row.append(readCell); + + let deleteCell = document.createElement("td"); + let deleteB = document.createElement("button"); + let icon = document.createElement("ion-icon"); + icon.setAttribute("name", "trash-outline"); + deleteButton.classList.add("delete"); + deleteButton.setAttribute("type", "button"); + deleteButton.setAttribute("data-book", bookNumber); + + deleteButton.append(icon); + deleteCell.append(deleteButton); + row.append(deleteCell); + + tableBody.insertBefore(row, tableBody.firstChild); + + addDeletedButtons(); + addReadButtons(); + + bookNumber++; + } + } +} + +submit.addEventListener("click", (e) => { + e.preventDefault(); + + let form = document.querySelector("form"); + let bookArgs = []; + + for (let i = 0; i < form.elements.length; i++) { + let element = form.elements[i]; + if (element.id === "read") { + if(element.checked === true){ + bookArgs.push("No"); + }else{ + bookArgs.push("Yes"); + } + element.checked = false; + } else { + bookArgs.push(element.value); + if (element.id !== "submit") { + element.value = ""; + } + } + } + + formContainer.style.display = "none"; + addBookToLibrary(bookArgs[1], bookArgs[0], bookArgs[2], bookArgs[3]); + render(); +}); diff --git a/week-7/InClass/3-Debugging-Library-Code/styles/main.css b/week-7/InClass/3-Debugging-Library-Code/styles/main.css new file mode 100644 index 000000000..9ad03632d --- /dev/null +++ b/week-7/InClass/3-Debugging-Library-Code/styles/main.css @@ -0,0 +1,308 @@ +body { + background-color: #fffaed; + font-size: 10px; +} + +#h1-container { + display: flex; + justify-content: center; + margin-top: 5vh; +} + +h1 { + font-size: 5em; +} + +#mobile-button-container { + display: flex; + justify-content: center; + margin: 3vh 0; +} + +.add-button { + position: relative; + width: 100px; + height: 30px; + margin-left: 30px; + margin-top: 15px; + color: #ffffff; + font-weight: bold; + background-color: green; + text-align: center; + border: none; + outline: none; +} + +.add-button:hover { + cursor: pointer; + background-color: #007400; + transform: scale(1.2); +} + +#add-button-mobile { + margin: 0; +} + +#add-button-mobile:before { + content: ""; + position: absolute; + right: 0px; + top: 100%; + width: 0px; + height: 0px; + border-right: 50px solid transparent; + border-left: 50px solid transparent; + border-top: 15px solid green; +} + +#add-button-mobile:hover:before { + border-top-color: #007400; +} + +#form-container { + display: none; +} + +#inputs-container { + display: flex; + flex-direction: column; + align-items: center; +} + +.input { + margin-top: 1vh; + display: flex; + align-items: center; + justify-content: space-between; + width: 75vw; +} + +#input-group { + display: flex; + justify-content: center; + width: 75vw; +} + +.small-input { + display: flex; + align-items: center; + justify-content: space-between; + width: 20vw; + margin: 2vw 5vw 0 0; +} + +#checkbox-container { + width: 12vw; +} + +.text-input { + width: 60vw; +} + +#input-group { + display: flex; + width: 60vw; +} + +#pages { + width: 10vw; +} + +#read { + margin: 0 0 1px 0; +} + +#submit-container { + margin-top: 1vh; +} + +#submit-container input { + background-color: green; + color: white; + border: none; + outline: none; + font-weight: bold; + padding: 5px 10px; +} + +#main-container { + display: flex; + justify-content: center; + margin-top: 5vh; +} + +table { + border-collapse: separate; + border-spacing: 0 5px; +} + +.color-row { + background-color: #ece0c3; +} + +.color-row td { + padding: 7px 0; +} + +th { + font-size: 1.6em; + font-weight: bold; + padding: 0 1vw 0 1vw; +} + +td { + font-size: 1em; + text-align: center; + vertical-align: middle; + padding: 2px 1vw 2px 1vw; +} + +.change-read { + color: white; + font-weight: bold; + font-size: 1em; + width: 35px; + padding: 4px 0; +} + +.button-green { + background-color: green; +} + +.button-red { + background-color: #d20000; +} + +.button-green:hover { + background-color: #007400; +} + +.button-red:hover { + background-color: #c70000; +} + +td button { + border: none; + outline: none; + background: none; + cursor: pointer; +} + +#desktop-button-container { + display: flex; +} + +#add-button-desktop:before { + content: ""; + position: absolute; + right: 100%; + top: 0px; + width: 0px; + height: 0px; + border-top: 15px solid transparent; + border-right: 15px solid green; + border-bottom: 15px solid transparent; +} + +#add-button-desktop:hover:before { + border-right-color: #007400; +} + +#add-button-desktop { + display: none; +} + +@media only screen and (min-width: 768px) { + body { + font-size: 14px; + } + + #mobile-button-container { + display: none; + } + + #form-container { + margin-top: 5vh; + } + + #inputs-container { + flex-direction: row; + justify-content: center; + } + + .input { + flex-direction: column; + margin: 0 20px; + width: 200px; + } + + .text-input { + width: 200px; + } + + .small-input { + flex-direction: column; + width: 50px; + margin: 0 20px; + } + + #input-group { + width: 100px; + margin: 0 20px; + } + + #pages { + width: 50px; + } + + #checkbox-container { + width: 50px; + } + + #submit-container { + align-self: flex-end; + margin: 0 0 0 20px; + } + + #submit-container input { + width: 80px; + height: 30px; + } + + #submit-container input:hover { + cursor: pointer; + } + + #add-button-desktop { + display: inline-block; + } + + #table-container { + margin-left: 130px; /* centers the table by giving it a left margin of the size+margin of the add button */ + } + + th { + font-size: 2em; + } + + td { + font-size: 1.4em; + } + + td .delete:hover { + transform: scale(1.5); + } + + .change-read { + width: 50px; + } + + .button-green:hover, + .button-red:hover { + transform: scale(1.3); + } + + ion-icon { + font-size: 1.4em; + } +} diff --git a/week-7/InClass/3-Debugging-Library-Code/styles/reset.css b/week-7/InClass/3-Debugging-Library-Code/styles/reset.css new file mode 100644 index 000000000..45a05ecf8 --- /dev/null +++ b/week-7/InClass/3-Debugging-Library-Code/styles/reset.css @@ -0,0 +1,129 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +strong, +sub, +sup, +tt, +var, +b, +u, +i, +center, +dl, +dt, +dd, +ol, +ul, +li, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td, +article, +aside, +canvas, +details, +embed, +figure, +figcaption, +footer, +header, +hgroup, +menu, +nav, +output, +ruby, +section, +summary, +time, +mark, +audio, +video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +menu, +nav, +section { + display: block; +} +body { + line-height: 1; +} +ol, +ul { + list-style: none; +} +blockquote, +q { + quotes: none; +} +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ""; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} From 11ef69dedb9602c9bb95ad35d2f1dd05bb6c3aaf Mon Sep 17 00:00:00 2001 From: Andrei Date: Mon, 29 Jun 2020 18:51:56 +0100 Subject: [PATCH 31/37] Completed InClass exercises --- week-7/InClass/1-Errors/exercise1.js | 4 ++- week-7/InClass/1-Errors/exercise2.js | 6 ++-- week-7/InClass/1-Errors/exercise3.js | 4 +-- week-7/InClass/1-Errors/exercise4.js | 4 +-- week-7/InClass/1-Errors/exercise5.js | 14 ++++----- week-7/InClass/2-Debugging/exercise1.js | 8 ++--- week-7/InClass/2-Debugging/exercise2.js | 7 +++-- week-7/InClass/2-Debugging/exercise3.js | 16 +++++----- week-7/InClass/2-Debugging/exercise4.js | 12 ++++---- week-7/InClass/2-Debugging/exercise5.js | 16 +++++----- week-7/InClass/2-Debugging/exercise6.js | 6 ++-- .../3-Debugging-Library-Code/index.html | 2 +- .../InClass/3-Debugging-Library-Code/main.js | 29 +++++++++---------- 13 files changed, 66 insertions(+), 62 deletions(-) diff --git a/week-7/InClass/1-Errors/exercise1.js b/week-7/InClass/1-Errors/exercise1.js index be0c54586..dc7d6f489 100644 --- a/week-7/InClass/1-Errors/exercise1.js +++ b/week-7/InClass/1-Errors/exercise1.js @@ -14,4 +14,6 @@ let myAge = 44; myAge = myAge.toUpperCase(); -console.log(myAge); \ No newline at end of file +console.log(myAge); + +//because myAge's value is a number, not string, we can add quotes around it, an it will work. diff --git a/week-7/InClass/1-Errors/exercise2.js b/week-7/InClass/1-Errors/exercise2.js index f6bb295ad..97594728e 100644 --- a/week-7/InClass/1-Errors/exercise2.js +++ b/week-7/InClass/1-Errors/exercise2.js @@ -5,6 +5,6 @@ Then please fix the error! */ let myAge = 25; -if myAge > 18 { - console.log("Yes can vote"); -} \ No newline at end of file +if (myAge > 18) { + console.log("Yes can vote"); +} diff --git a/week-7/InClass/1-Errors/exercise3.js b/week-7/InClass/1-Errors/exercise3.js index 9aa38d41d..836d932d9 100644 --- a/week-7/InClass/1-Errors/exercise3.js +++ b/week-7/InClass/1-Errors/exercise3.js @@ -3,6 +3,6 @@ type of error, and see which line the error is on Then please fix the error! */ -// let greeting = "Hello"; +let greeting = "Hello"; -console.log(greeting); \ No newline at end of file +console.log(greeting); diff --git a/week-7/InClass/1-Errors/exercise4.js b/week-7/InClass/1-Errors/exercise4.js index 2da79db59..363322322 100644 --- a/week-7/InClass/1-Errors/exercise4.js +++ b/week-7/InClass/1-Errors/exercise4.js @@ -3,8 +3,8 @@ type of error, and see which line the error is on Then please fix the error! */ -let ages; // = [4, 28, 55, 15]; +let ages = [4, 28, 55, 15]; let a = ages.length; -console.log(a); \ No newline at end of file +console.log(a); diff --git a/week-7/InClass/1-Errors/exercise5.js b/week-7/InClass/1-Errors/exercise5.js index 3d8188f79..0534ac5b4 100644 --- a/week-7/InClass/1-Errors/exercise5.js +++ b/week-7/InClass/1-Errors/exercise5.js @@ -3,17 +3,17 @@ type of error, and see which line the error is on Then please fix the error! */ -function calculateAgeInMonths(ages){ - let newArray = ages.map(multiplyBy12); - return newArray; +function calculateAgeInMonths(ages) { + let newArray = ages.map(multiplyBy12); + return newArray; } -function multiplyBy12(age){ - return age * 12; +function multiplyBy12(age) { + return age * 12; } let peopleAges = [4, 28, 55, 15]; -let agesInMonths = calculateAgeInMonths(); +let agesInMonths = calculateAgeInMonths(peopleAges); -console.log(agesInMonths); \ No newline at end of file +console.log(agesInMonths); diff --git a/week-7/InClass/2-Debugging/exercise1.js b/week-7/InClass/2-Debugging/exercise1.js index b510977b2..8ac46daaa 100644 --- a/week-7/InClass/2-Debugging/exercise1.js +++ b/week-7/InClass/2-Debugging/exercise1.js @@ -5,12 +5,12 @@ output. Why is the bug happening? How do we fix it? */ -function capitaliseName(name){ - return name.toUpperCase(); +function capitaliseName(name) { + return name.toUpperCase(); } let myName = "santanu"; -capitaliseName(myName); +myName = capitaliseName(myName); -console.log(myName); \ No newline at end of file +console.log(myName); diff --git a/week-7/InClass/2-Debugging/exercise2.js b/week-7/InClass/2-Debugging/exercise2.js index 21ee6d171..2168ce648 100644 --- a/week-7/InClass/2-Debugging/exercise2.js +++ b/week-7/InClass/2-Debugging/exercise2.js @@ -5,12 +5,13 @@ output. Why is the bug happening? How do we fix it? */ -function greet(firstName, lastName){ - console.log("Hello " + firstName + " " + lastName); +function greet(firstName, lastName) { + console.log("Hello " + firstName + " " + lastName); } let myFirstName = "Safra"; let mySurname = "Catz"; -greet(myFirstName); \ No newline at end of file +greet(myFirstName, mySurname); +//we did not call function properly - we need to call it with both parameters diff --git a/week-7/InClass/2-Debugging/exercise3.js b/week-7/InClass/2-Debugging/exercise3.js index 65f558e3a..5b96072d8 100644 --- a/week-7/InClass/2-Debugging/exercise3.js +++ b/week-7/InClass/2-Debugging/exercise3.js @@ -7,18 +7,18 @@ output. Why is the bug happening? How do we fix it? */ -function canDrive(a){ - if(a <= 17){ - return true; - }else{ - return false; - } +function canDrive(a) { + if (a <= 17) { + return false; + } else { + return true; + } } const ages = [22, 15, 29, 31, 7, 54, 13]; -const legalDrivers = ages.filter(canDrive); +const legalDrivers = ages.filter(canDrive(ages)); console.log(legalDrivers); -// We'd better fix this bug or our company will be sending out provisional driving licences to children! \ No newline at end of file +// We'd better fix this bug or our company will be sending out provisional driving licences to children! diff --git a/week-7/InClass/2-Debugging/exercise4.js b/week-7/InClass/2-Debugging/exercise4.js index fa703b3e6..56fbeb5b9 100644 --- a/week-7/InClass/2-Debugging/exercise4.js +++ b/week-7/InClass/2-Debugging/exercise4.js @@ -9,12 +9,14 @@ is not a String, we should return the String "NO VALUE" - please modify the code to do this */ -function capitalise(customer){ - return customer.toUpperCase(); +function capitalise(customer) { + return customer.toUpperCase(); } -const messyNames = ["Sundar", "reshma", true, "Maria", "Shantanu", 5 ]; +const messyNames = ["Sundar", "reshma", true, "Maria", "Shantanu", 5]; -const customers = messyNames.map(capitalise); +const customers = messyNames + .filter((el) => typeof el == "string") + .map(capitalise); -console.log(customers); \ No newline at end of file +console.log(customers); diff --git a/week-7/InClass/2-Debugging/exercise5.js b/week-7/InClass/2-Debugging/exercise5.js index 7a3dfc8f5..d74dd408f 100644 --- a/week-7/InClass/2-Debugging/exercise5.js +++ b/week-7/InClass/2-Debugging/exercise5.js @@ -6,15 +6,15 @@ But our code prints out all the ages! How can we change line 20 so we only print ages of people who can vote? */ -function canVote(age){ - if(age >= 18){ - return true; - }else{ - return false; - } +function canVote(age) { + if (age >= 18) { + return true; + } else { + return false; + } } const ages = [17, 26, 4, 18, 7, 12, 31]; -let voterAges = ages.filter(canVote); +let canVoter = ages.filter(canVote); -console.log(ages); \ No newline at end of file +console.log(canVoter); diff --git a/week-7/InClass/2-Debugging/exercise6.js b/week-7/InClass/2-Debugging/exercise6.js index da3b02932..0771e5d48 100644 --- a/week-7/InClass/2-Debugging/exercise6.js +++ b/week-7/InClass/2-Debugging/exercise6.js @@ -6,6 +6,6 @@ What is the problem, and can you fix it? let myName = "Sundar"; -if (myName = "Reshma" ){ - console.log("Hello"); -} \ No newline at end of file +if (myName == "Reshma") { + console.log("Hello"); +} diff --git a/week-7/InClass/3-Debugging-Library-Code/index.html b/week-7/InClass/3-Debugging-Library-Code/index.html index 3ab2800bd..4255bdd17 100644 --- a/week-7/InClass/3-Debugging-Library-Code/index.html +++ b/week-7/InClass/3-Debugging-Library-Code/index.html @@ -77,6 +77,6 @@

Odin's Library

- + diff --git a/week-7/InClass/3-Debugging-Library-Code/main.js b/week-7/InClass/3-Debugging-Library-Code/main.js index 02ff2faec..80cd3e708 100644 --- a/week-7/InClass/3-Debugging-Library-Code/main.js +++ b/week-7/InClass/3-Debugging-Library-Code/main.js @@ -1,7 +1,7 @@ const addButtons = document.querySelectorAll(".add-button"); const formContainer = document.getElementById("form-container"); const tableBody = document.getElementById("table-body"); -const submitted = document.getElementById("submitted"); +const submit = document.getElementById("submit"); let bookNumber = 0; let myLibrary = []; @@ -19,7 +19,7 @@ const book2 = { read: "No", }; -myLibrary.push(book1; +myLibrary.push(book1); myLibrary.push(book2); render(); @@ -28,15 +28,14 @@ addButtons.forEach((button) => { button.addEventListener("click", () => { formContainer.style.display = "block"; }); -}; +}); function addDeleteButtons() { let deleteButtons = document.querySelectorAll(".delete"); - deleteButtons.forEach((button) => { if (button.getAttribute("data-book") == bookNumber) { //Only add eventListeners to new books - button.addEventListener("clicksss", () => { + button.addEventListener("click", () => { deleteBook(button.getAttribute("data-book")); }); } @@ -93,7 +92,7 @@ function render() { let titleCell = document.createElement("td"); titleCell.append(myLibrary[i].title); - row.append(titleCella); + row.append(titleCell); let authorCell = document.createElement("td"); authorCell.append(myLibrary[i].author); @@ -123,17 +122,17 @@ function render() { let deleteB = document.createElement("button"); let icon = document.createElement("ion-icon"); icon.setAttribute("name", "trash-outline"); - deleteButton.classList.add("delete"); - deleteButton.setAttribute("type", "button"); - deleteButton.setAttribute("data-book", bookNumber); + deleteB.classList.add("delete"); + deleteB.setAttribute("type", "button"); + deleteB.setAttribute("data-book", bookNumber); - deleteButton.append(icon); - deleteCell.append(deleteButton); + deleteB.append(icon); + deleteCell.append(deleteB); row.append(deleteCell); tableBody.insertBefore(row, tableBody.firstChild); - addDeletedButtons(); + addDeleteButtons(); addReadButtons(); bookNumber++; @@ -150,10 +149,10 @@ submit.addEventListener("click", (e) => { for (let i = 0; i < form.elements.length; i++) { let element = form.elements[i]; if (element.id === "read") { - if(element.checked === true){ - bookArgs.push("No"); - }else{ + if (element.checked === true) { bookArgs.push("Yes"); + } else { + bookArgs.push("No"); } element.checked = false; } else { From aac016762078ed8f27f82c410c72bc832d4e53df Mon Sep 17 00:00:00 2001 From: r-darby Date: Tue, 30 Jun 2020 07:00:31 +0100 Subject: [PATCH 32/37] Create Function InClass exercises --- .../InClass/1-Calling-Functions/exercise1.js | 23 ++++++++++++ .../InClass/1-Calling-Functions/exercise2.js | 25 +++++++++++++ .../InClass/1-Calling-Functions/exercise3.js | 25 +++++++++++++ .../InClass/1-Calling-Functions/exercise4.js | 21 +++++++++++ .../InClass/1-Calling-Functions/exercise5.js | 25 +++++++++++++ week-8/InClass/2-Functions/exercise1.js | 19 ++++++++++ week-8/InClass/2-Functions/exercise2.js | 23 ++++++++++++ week-8/InClass/2-Functions/exercise3.js | 18 ++++++++++ week-8/InClass/2-Functions/exercise4.js | 22 ++++++++++++ .../InClass/2-Functions/exercise5-example1.js | 33 +++++++++++++++++ .../InClass/2-Functions/exercise5-example2.js | 35 +++++++++++++++++++ .../InClass/2-Functions/exercise5-question.js | 28 +++++++++++++++ 12 files changed, 297 insertions(+) create mode 100644 week-8/InClass/1-Calling-Functions/exercise1.js create mode 100644 week-8/InClass/1-Calling-Functions/exercise2.js create mode 100644 week-8/InClass/1-Calling-Functions/exercise3.js create mode 100644 week-8/InClass/1-Calling-Functions/exercise4.js create mode 100644 week-8/InClass/1-Calling-Functions/exercise5.js create mode 100644 week-8/InClass/2-Functions/exercise1.js create mode 100644 week-8/InClass/2-Functions/exercise2.js create mode 100644 week-8/InClass/2-Functions/exercise3.js create mode 100644 week-8/InClass/2-Functions/exercise4.js create mode 100644 week-8/InClass/2-Functions/exercise5-example1.js create mode 100644 week-8/InClass/2-Functions/exercise5-example2.js create mode 100644 week-8/InClass/2-Functions/exercise5-question.js diff --git a/week-8/InClass/1-Calling-Functions/exercise1.js b/week-8/InClass/1-Calling-Functions/exercise1.js new file mode 100644 index 000000000..9323deee0 --- /dev/null +++ b/week-8/InClass/1-Calling-Functions/exercise1.js @@ -0,0 +1,23 @@ +/* +ONLY CHANGE LINE 21 to answer this question + +This code has a bug - if we run it we see the result "Hello undefined" + +Why are we getting this result? + +Please fix this code so we get the result "Hello Marissa" + +ONLY CHANGE LINE 21 +*/ + +function greet(name){ + name = "Hello " + name; + return name; +} + +let myName = "Marissa"; + +// ONLY CHANGE CODE ON LINE 21 +let greeting = greet(); + +console.log(greeting); \ No newline at end of file diff --git a/week-8/InClass/1-Calling-Functions/exercise2.js b/week-8/InClass/1-Calling-Functions/exercise2.js new file mode 100644 index 000000000..fc272d753 --- /dev/null +++ b/week-8/InClass/1-Calling-Functions/exercise2.js @@ -0,0 +1,25 @@ +/* +ONLY CHANGE LINE 23 to answer this question + +This code has a bug - if we run it we see the result "NaN" +This means "Not a Number", we get this when we try to multiply (or divide, add, subtract etc) +a variable which is not of type = number + +Why are we getting this result? + +Please fix this code so we get the result 10 + +ONLY CHANGE LINE 23 +*/ + +function doubleNumber(num){ + num = num * 2; + return num; +} + +let a = 5; + +// ONLY CHANGE CODE ON LINE 23 +let b = doubleNumber(); + +console.log(b); \ No newline at end of file diff --git a/week-8/InClass/1-Calling-Functions/exercise3.js b/week-8/InClass/1-Calling-Functions/exercise3.js new file mode 100644 index 000000000..3b0be6b9c --- /dev/null +++ b/week-8/InClass/1-Calling-Functions/exercise3.js @@ -0,0 +1,25 @@ +/* +ONLY CHANGE LINE 23 to answer this question + +This code has a bug - if we run it we see the result "John undefined" + +Why are we getting this result? + +Please fix this code so we get the result "John Legere" + +ONLY CHANGE LINE 23 +*/ + +function fullName(firstName, surname){ + let fullName = firstName + " " + surname; + return fullName; +} + +let customerFirstName = "John"; + +let customerSurname = "Legere"; + +// ONLY CHANGE CODE ON LINE 23 +let customerFullName = fullName(customerFirstName); + +console.log(customerFullName); \ No newline at end of file diff --git a/week-8/InClass/1-Calling-Functions/exercise4.js b/week-8/InClass/1-Calling-Functions/exercise4.js new file mode 100644 index 000000000..c3d73ef88 --- /dev/null +++ b/week-8/InClass/1-Calling-Functions/exercise4.js @@ -0,0 +1,21 @@ +/* +ONLY CHANGE LINE 19 to answer this question + +We would like to see the result "10" but we are getting result "5" + +Please change this code so we get the result 10 + +ONLY CHANGE LINE 19 +*/ + +function doubleNumber(num){ + num = num * 2; + return num; +} + +let a = 5; + +// ONLY CHANGE CODE ON LINE 19 +doubleNumber(a); + +console.log(a); \ No newline at end of file diff --git a/week-8/InClass/1-Calling-Functions/exercise5.js b/week-8/InClass/1-Calling-Functions/exercise5.js new file mode 100644 index 000000000..90ea46cef --- /dev/null +++ b/week-8/InClass/1-Calling-Functions/exercise5.js @@ -0,0 +1,25 @@ +/* +ONLY CHANGE LINE 23 to answer this question + +This code has a bug - run it and see what the result is + +Why are we getting this result? + +Please fix this code so we get the result "38" + +ONLY CHANGE LINE 23 +*/ + +function calculateAge(yearOfBirth, currentYear){ + let age = currentYear - yearOfBirth; + return age; +} + +let yearIWasBorn = 1982; + +let thisYear = 2020; + +// ONLY CHANGE CODE ON LINE 23 +let myAge = calculateAge(thisYear, yearIWasBorn); + +console.log(myAge); \ No newline at end of file diff --git a/week-8/InClass/2-Functions/exercise1.js b/week-8/InClass/2-Functions/exercise1.js new file mode 100644 index 000000000..0dc4b9b7f --- /dev/null +++ b/week-8/InClass/2-Functions/exercise1.js @@ -0,0 +1,19 @@ +/* +What is the value we expect to see in the console? + +Why do we see "undefined"? + +ONLY CHANGE the code of calculateAgeInMonths function - +please fix this bug so we see the result is "360" +*/ + +function calculateAgeInMonths(ageInYears){ + let ageInMonths = ageInYears * 12; + +} + +let myAge = 30; + +let myAgeInMonths = calculateAgeInMonths(myAge); + +console.log(myAgeInMonths); \ No newline at end of file diff --git a/week-8/InClass/2-Functions/exercise2.js b/week-8/InClass/2-Functions/exercise2.js new file mode 100644 index 000000000..5c9b6660b --- /dev/null +++ b/week-8/InClass/2-Functions/exercise2.js @@ -0,0 +1,23 @@ +/* +What is the value we expect to see in the console? + +What is the TYPE of error, and what LINE NUMBER does it happen at? What is the ERROR MESSAGE? + +Why are we getting this error? + +ONLY CHANGE the code of calculateArea function - +please fix this bug so we see the result is "30" +*/ + +function calculateArea(x){ + let areaValue = x * y; + return areaValue; +} + +let width = 10; + +let height = 3; + +let area = calculateArea(width, height); + +console.log(area); \ No newline at end of file diff --git a/week-8/InClass/2-Functions/exercise3.js b/week-8/InClass/2-Functions/exercise3.js new file mode 100644 index 000000000..dd6b1b6e1 --- /dev/null +++ b/week-8/InClass/2-Functions/exercise3.js @@ -0,0 +1,18 @@ +/* +In this exercise, you have to write the code for the function! + +ONLY change the code inside the calculateArea function +*/ + +function calculateArea(x, y){ + // write your code here + +} + +let width = 5; + +let height = 10; + +let area = calculateArea(width, height); + +console.log(area); \ No newline at end of file diff --git a/week-8/InClass/2-Functions/exercise4.js b/week-8/InClass/2-Functions/exercise4.js new file mode 100644 index 000000000..325ae1dcd --- /dev/null +++ b/week-8/InClass/2-Functions/exercise4.js @@ -0,0 +1,22 @@ +/* +In this exercise, you have to make the code work +by writing a function! + +Look at where the function is being called (line 20) +What is the name of the function we need? +How many input parameters do we need? +What is the result we need to return? + +To complete this exercise you ONLY need to +write the function +*/ + +// write your function here + + +// Don't change any of the code below +let years = 5; + +let months = calculateMonthsInYear(years); + +console.log(months); \ No newline at end of file diff --git a/week-8/InClass/2-Functions/exercise5-example1.js b/week-8/InClass/2-Functions/exercise5-example1.js new file mode 100644 index 000000000..6767de7ca --- /dev/null +++ b/week-8/InClass/2-Functions/exercise5-example1.js @@ -0,0 +1,33 @@ +/* +READ ONLY - this is an example to help you with the next question. + +We have written code which does the SAME calculation 3 times! +Remember the DRY principle - Don't Repeat Yourself. +This is a good time to use a function. + +We can write a function to do the calculation, and +change our code so it CALLS the function 3 times + +When we change our code like this we say we are REFACTORING + +Look at exercise5-example2.js to see the refactored code. +*/ + +let width1 = 10; +let height1 = 2; +let length1 = 3; +let volume1 = width1 * height1 * length1; + +let width2 = 4; +let height2 = 6; +let length2 = 2; +let volume2 = width2 * height2 * length2; + +let width3 = 8; +let height3 = 3; +let length3 = 5; +let volume3 = width3 * height3 * length3; + +console.log(volume1); +console.log(volume2); +console.log(volume3); diff --git a/week-8/InClass/2-Functions/exercise5-example2.js b/week-8/InClass/2-Functions/exercise5-example2.js new file mode 100644 index 000000000..fa859ba14 --- /dev/null +++ b/week-8/InClass/2-Functions/exercise5-example2.js @@ -0,0 +1,35 @@ +/* +READ ONLY - this is an example to help you with the next question. + +Now we have refactored the code so our calculation is only written once. +If we ever have to change it, we only need to change it in one place. + +Remember after refactoring we should still get the SAME result! +Check the output of this code with the last one to check the results are the same. + +Now do exercise5-question.js. +*/ + +function calculateVolume(x, y, z){ + let volume = x * y * z; + return volume; +} + +let width1 = 10; +let height1 = 2; +let length1 = 3; +let volume1 = calculateVolume(width1, height1, length1); + +let width2 = 4; +let height2 = 6; +let length2 = 2; +let volume2 = calculateVolume(width2, height2, length2); + +let width3 = 8; +let height3 = 3; +let length3 = 5; +let volume3 = calculateVolume(width3, height3, length3); + +console.log(volume1); +console.log(volume2); +console.log(volume3); diff --git a/week-8/InClass/2-Functions/exercise5-question.js b/week-8/InClass/2-Functions/exercise5-question.js new file mode 100644 index 000000000..792d4a655 --- /dev/null +++ b/week-8/InClass/2-Functions/exercise5-question.js @@ -0,0 +1,28 @@ +/* +We have written code below that does the same thing 3 times. + +We should REFACTOR this code. + +We should write a function, and call the function 3 times. + +The results should stay THE SAME +*/ + +let firstName1 = "Katrina"; +let surname1 = "Lake"; +// Change the line below to call your function! +let greeting1 = "Hello " + firstName1 + " " + surname1; + +let firstName2 = "Eric"; +let surname2 = "Yuan"; +// Change the line below to call your function! +let greeting2 = "Hello " + firstName2 + " " + surname2; + +let firstName3 = "Jeff"; +let surname3 = "Bezos"; +// Change the line below to call your function! +let greeting3 = "Hello " + firstName3 + " " + surname3; + +console.log(greeting1); +console.log(greeting2); +console.log(greeting3); From 379c59e1ac5916e07d264d30d0232295d21514ba Mon Sep 17 00:00:00 2001 From: Rares Matei Date: Fri, 3 Jul 2020 23:39:44 +0100 Subject: [PATCH 33/37] add fetch and API exercises --- week-8/InClass/3-fetch/data.json | 10 ++++++++++ week-8/InClass/3-fetch/exercise.js | 7 +++++++ week-8/InClass/3-fetch/index.html | 11 +++++++++++ week-8/InClass/4-APIs/exercise.js | 9 +++++++++ week-8/InClass/4-APIs/index.html | 11 +++++++++++ 5 files changed, 48 insertions(+) create mode 100644 week-8/InClass/3-fetch/data.json create mode 100644 week-8/InClass/3-fetch/exercise.js create mode 100644 week-8/InClass/3-fetch/index.html create mode 100644 week-8/InClass/4-APIs/exercise.js create mode 100644 week-8/InClass/4-APIs/index.html diff --git a/week-8/InClass/3-fetch/data.json b/week-8/InClass/3-fetch/data.json new file mode 100644 index 000000000..e756f5407 --- /dev/null +++ b/week-8/InClass/3-fetch/data.json @@ -0,0 +1,10 @@ +[ + { + "name": "Alex", + "age": 21 + }, + { + "name": "Anna", + "age": 52 + } +] \ No newline at end of file diff --git a/week-8/InClass/3-fetch/exercise.js b/week-8/InClass/3-fetch/exercise.js new file mode 100644 index 000000000..a1f22a2ca --- /dev/null +++ b/week-8/InClass/3-fetch/exercise.js @@ -0,0 +1,7 @@ +/* + 1. Fetch the "people" array from the "data.json" file + 2. And console.log() the name of the first person. + + Remember to open "index.html" using Live Preview, and test that you get the correct results in the console! + (you should see "Alex") + */ diff --git a/week-8/InClass/3-fetch/index.html b/week-8/InClass/3-fetch/index.html new file mode 100644 index 000000000..02e424a19 --- /dev/null +++ b/week-8/InClass/3-fetch/index.html @@ -0,0 +1,11 @@ + + + + + Fetch + + + + Open the console to see your results! + + diff --git a/week-8/InClass/4-APIs/exercise.js b/week-8/InClass/4-APIs/exercise.js new file mode 100644 index 000000000..f9e06c8a1 --- /dev/null +++ b/week-8/InClass/4-APIs/exercise.js @@ -0,0 +1,9 @@ +/* + 1. Fetch the results from this API: https://cat-fact.herokuapp.com/facts + And console.log the first cat fact + + 2. Fetch the results from this API: https://restcountries.eu/rest/v2/name/Great%20Britain?fullText=true + And console.log the population of the UK + + Remember to open "index.html" using Live Preview, and test that you get the correct results in the console! + */ diff --git a/week-8/InClass/4-APIs/index.html b/week-8/InClass/4-APIs/index.html new file mode 100644 index 000000000..02e424a19 --- /dev/null +++ b/week-8/InClass/4-APIs/index.html @@ -0,0 +1,11 @@ + + + + + Fetch + + + + Open the console to see your results! + + From 0126d483fe2a3da984c558df4145b2c73fd3ec40 Mon Sep 17 00:00:00 2001 From: Andrei Date: Sat, 4 Jul 2020 10:23:39 +0100 Subject: [PATCH 34/37] Added something --- week-7/Homework/mandatory/1-debugging-practice/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/week-7/Homework/mandatory/1-debugging-practice/script.js b/week-7/Homework/mandatory/1-debugging-practice/script.js index dc14a775a..0ba49c50d 100644 --- a/week-7/Homework/mandatory/1-debugging-practice/script.js +++ b/week-7/Homework/mandatory/1-debugging-practice/script.js @@ -54,7 +54,7 @@ function render() { let table = document.getElementById("display"); let rowsNumber = table.rows.length; //delete old table - for (let n = rowsNumber - 1; n > 0; n-- { + for (let n = rowsNumber - 1; n > 0; n--) { table.deleteRow(n); } //insert updated row and cells From 8af4c24e4d69719c28f1141fbe21534a789b5fd1 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 9 Jul 2020 23:49:04 +0100 Subject: [PATCH 35/37] Added INCLASS exercises --- week-8/InClass/1-Calling-Functions/exercise1.js | 10 +++++----- week-8/InClass/1-Calling-Functions/exercise2.js | 10 +++++----- week-8/InClass/1-Calling-Functions/exercise3.js | 10 +++++----- week-8/InClass/1-Calling-Functions/exercise4.js | 10 +++++----- week-8/InClass/1-Calling-Functions/exercise5.js | 10 +++++----- week-8/InClass/2-Functions/exercise1.js | 8 ++++---- week-8/InClass/2-Functions/exercise2.js | 8 ++++---- week-8/InClass/2-Functions/exercise3.js | 8 ++++---- week-8/InClass/2-Functions/exercise4.js | 10 +++++----- .../InClass/2-Functions/exercise5-question.js | 10 +++++++--- week-8/InClass/3-fetch/exercise.js | 8 ++++++++ week-8/InClass/4-APIs/exercise.js | 17 +++++++++++++++++ 12 files changed, 74 insertions(+), 45 deletions(-) diff --git a/week-8/InClass/1-Calling-Functions/exercise1.js b/week-8/InClass/1-Calling-Functions/exercise1.js index 9323deee0..a3e5e948f 100644 --- a/week-8/InClass/1-Calling-Functions/exercise1.js +++ b/week-8/InClass/1-Calling-Functions/exercise1.js @@ -10,14 +10,14 @@ Please fix this code so we get the result "Hello Marissa" ONLY CHANGE LINE 21 */ -function greet(name){ - name = "Hello " + name; - return name; +function greet(name) { + name = "Hello " + name; + return name; } let myName = "Marissa"; // ONLY CHANGE CODE ON LINE 21 -let greeting = greet(); +let greeting = greet(myName); -console.log(greeting); \ No newline at end of file +console.log(greeting); diff --git a/week-8/InClass/1-Calling-Functions/exercise2.js b/week-8/InClass/1-Calling-Functions/exercise2.js index fc272d753..92ebcbbe7 100644 --- a/week-8/InClass/1-Calling-Functions/exercise2.js +++ b/week-8/InClass/1-Calling-Functions/exercise2.js @@ -12,14 +12,14 @@ Please fix this code so we get the result 10 ONLY CHANGE LINE 23 */ -function doubleNumber(num){ - num = num * 2; - return num; +function doubleNumber(num) { + num = num * 2; + return num; } let a = 5; // ONLY CHANGE CODE ON LINE 23 -let b = doubleNumber(); +let b = doubleNumber(a); -console.log(b); \ No newline at end of file +console.log(b); diff --git a/week-8/InClass/1-Calling-Functions/exercise3.js b/week-8/InClass/1-Calling-Functions/exercise3.js index 3b0be6b9c..0a666535e 100644 --- a/week-8/InClass/1-Calling-Functions/exercise3.js +++ b/week-8/InClass/1-Calling-Functions/exercise3.js @@ -10,9 +10,9 @@ Please fix this code so we get the result "John Legere" ONLY CHANGE LINE 23 */ -function fullName(firstName, surname){ - let fullName = firstName + " " + surname; - return fullName; +function fullName(firstName, surname) { + let fullName = firstName + " " + surname; + return fullName; } let customerFirstName = "John"; @@ -20,6 +20,6 @@ let customerFirstName = "John"; let customerSurname = "Legere"; // ONLY CHANGE CODE ON LINE 23 -let customerFullName = fullName(customerFirstName); +let customerFullName = fullName(customerFirstName, customerSurname); -console.log(customerFullName); \ No newline at end of file +console.log(customerFullName); diff --git a/week-8/InClass/1-Calling-Functions/exercise4.js b/week-8/InClass/1-Calling-Functions/exercise4.js index c3d73ef88..18ad42362 100644 --- a/week-8/InClass/1-Calling-Functions/exercise4.js +++ b/week-8/InClass/1-Calling-Functions/exercise4.js @@ -8,14 +8,14 @@ Please change this code so we get the result 10 ONLY CHANGE LINE 19 */ -function doubleNumber(num){ - num = num * 2; - return num; +function doubleNumber(num) { + num = num * 2; + return num; } let a = 5; // ONLY CHANGE CODE ON LINE 19 -doubleNumber(a); +a = doubleNumber(a); -console.log(a); \ No newline at end of file +console.log(a); diff --git a/week-8/InClass/1-Calling-Functions/exercise5.js b/week-8/InClass/1-Calling-Functions/exercise5.js index 90ea46cef..167fc2c4f 100644 --- a/week-8/InClass/1-Calling-Functions/exercise5.js +++ b/week-8/InClass/1-Calling-Functions/exercise5.js @@ -10,9 +10,9 @@ Please fix this code so we get the result "38" ONLY CHANGE LINE 23 */ -function calculateAge(yearOfBirth, currentYear){ - let age = currentYear - yearOfBirth; - return age; +function calculateAge(yearOfBirth, currentYear) { + let age = currentYear - yearOfBirth; + return age; } let yearIWasBorn = 1982; @@ -20,6 +20,6 @@ let yearIWasBorn = 1982; let thisYear = 2020; // ONLY CHANGE CODE ON LINE 23 -let myAge = calculateAge(thisYear, yearIWasBorn); +let myAge = calculateAge(yearIWasBorn, thisYear); -console.log(myAge); \ No newline at end of file +console.log(myAge); diff --git a/week-8/InClass/2-Functions/exercise1.js b/week-8/InClass/2-Functions/exercise1.js index 0dc4b9b7f..5cf995e3e 100644 --- a/week-8/InClass/2-Functions/exercise1.js +++ b/week-8/InClass/2-Functions/exercise1.js @@ -7,13 +7,13 @@ ONLY CHANGE the code of calculateAgeInMonths function - please fix this bug so we see the result is "360" */ -function calculateAgeInMonths(ageInYears){ - let ageInMonths = ageInYears * 12; - +function calculateAgeInMonths(ageInYears) { + let ageInMonths = ageInYears * 12; + return ageInMonths; } let myAge = 30; let myAgeInMonths = calculateAgeInMonths(myAge); -console.log(myAgeInMonths); \ No newline at end of file +console.log(myAgeInMonths); diff --git a/week-8/InClass/2-Functions/exercise2.js b/week-8/InClass/2-Functions/exercise2.js index 5c9b6660b..b13409d8e 100644 --- a/week-8/InClass/2-Functions/exercise2.js +++ b/week-8/InClass/2-Functions/exercise2.js @@ -9,9 +9,9 @@ ONLY CHANGE the code of calculateArea function - please fix this bug so we see the result is "30" */ -function calculateArea(x){ - let areaValue = x * y; - return areaValue; +function calculateArea(x, y) { + let areaValue = x * y; + return areaValue; } let width = 10; @@ -20,4 +20,4 @@ let height = 3; let area = calculateArea(width, height); -console.log(area); \ No newline at end of file +console.log(area); diff --git a/week-8/InClass/2-Functions/exercise3.js b/week-8/InClass/2-Functions/exercise3.js index dd6b1b6e1..067433c8f 100644 --- a/week-8/InClass/2-Functions/exercise3.js +++ b/week-8/InClass/2-Functions/exercise3.js @@ -4,9 +4,9 @@ In this exercise, you have to write the code for the function! ONLY change the code inside the calculateArea function */ -function calculateArea(x, y){ - // write your code here - +function calculateArea(x, y) { + // write your code here + return x * y; } let width = 5; @@ -15,4 +15,4 @@ let height = 10; let area = calculateArea(width, height); -console.log(area); \ No newline at end of file +console.log(area); diff --git a/week-8/InClass/2-Functions/exercise4.js b/week-8/InClass/2-Functions/exercise4.js index 325ae1dcd..1ec5743be 100644 --- a/week-8/InClass/2-Functions/exercise4.js +++ b/week-8/InClass/2-Functions/exercise4.js @@ -10,13 +10,13 @@ What is the result we need to return? To complete this exercise you ONLY need to write the function */ - -// write your function here - - +function calculateMonthsInYear(time) { + // write your function here + return time * 12; +} // Don't change any of the code below let years = 5; let months = calculateMonthsInYear(years); -console.log(months); \ No newline at end of file +console.log(months); diff --git a/week-8/InClass/2-Functions/exercise5-question.js b/week-8/InClass/2-Functions/exercise5-question.js index 792d4a655..9843e6eef 100644 --- a/week-8/InClass/2-Functions/exercise5-question.js +++ b/week-8/InClass/2-Functions/exercise5-question.js @@ -11,18 +11,22 @@ The results should stay THE SAME let firstName1 = "Katrina"; let surname1 = "Lake"; // Change the line below to call your function! -let greeting1 = "Hello " + firstName1 + " " + surname1; +let greeting1 = greeting(firstName1, surname1); let firstName2 = "Eric"; let surname2 = "Yuan"; // Change the line below to call your function! -let greeting2 = "Hello " + firstName2 + " " + surname2; +let greeting2 = greeting(firstName2, surname2); let firstName3 = "Jeff"; let surname3 = "Bezos"; // Change the line below to call your function! -let greeting3 = "Hello " + firstName3 + " " + surname3; +let greeting3 = greeting(firstName3, surname3); console.log(greeting1); console.log(greeting2); console.log(greeting3); + +function greeting(name, surname) { + return "Hello " + name + " " + surname; +} diff --git a/week-8/InClass/3-fetch/exercise.js b/week-8/InClass/3-fetch/exercise.js index a1f22a2ca..d5373dfc4 100644 --- a/week-8/InClass/3-fetch/exercise.js +++ b/week-8/InClass/3-fetch/exercise.js @@ -5,3 +5,11 @@ Remember to open "index.html" using Live Preview, and test that you get the correct results in the console! (you should see "Alex") */ +fetch("data.json") + // Get the response and extract the JSON + .then(function (response) { + return response.json(); + }) + .then(function (person) { + console.log(person[0].name); + }); diff --git a/week-8/InClass/4-APIs/exercise.js b/week-8/InClass/4-APIs/exercise.js index f9e06c8a1..fda766ecb 100644 --- a/week-8/InClass/4-APIs/exercise.js +++ b/week-8/InClass/4-APIs/exercise.js @@ -7,3 +7,20 @@ Remember to open "index.html" using Live Preview, and test that you get the correct results in the console! */ +fetch("https://cat-fact.herokuapp.com/facts") + .then(function (result) { + return result.json(); + }) + + .then(function (cat_info) { + console.log(cat_info.all[0].text); + }); + +fetch("https://restcountries.eu/rest/v2/name/Great%20Britain?fullText=true") + .then(function (result) { + return result.json(); + }) + + .then(function (uk_info) { + console.log(uk_info[0].population); + }); From 7f246e5c14506effe9c1e9a6a79cdabcb5891058 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 9 Jul 2020 23:56:45 +0100 Subject: [PATCH 36/37] Added 2-fetch-exercise --- .../mandatory/2-fetch-exercise/exercise.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js index fb3a39c2a..5acc7ff72 100644 --- a/week-8/Homework/mandatory/2-fetch-exercise/exercise.js +++ b/week-8/Homework/mandatory/2-fetch-exercise/exercise.js @@ -16,11 +16,14 @@ Expected result Open index.html in your browser. Every time you refresh the page, a different greeting should be displayed in the box. */ - -fetch('*** Write the API address here ***') - .then(function(response) { - return response.text(); +function setup() { + fetch("https://codeyourfuture.herokuapp.com/api/greetings") + .then(function (response) { + return response.text(); }) - .then(function(greeting) { - // Write the code to display the greeting text here - }); \ No newline at end of file + .then(function (greeting) { + // Write the code to display the greeting text here + document.querySelector("#greeting-text").textContent = greeting; + }); +} +window.onload = setup; From 92699852bdd032f8eb9a3953b412ca00c0d9d7b3 Mon Sep 17 00:00:00 2001 From: Andrei Date: Sat, 11 Jul 2020 22:43:38 +0100 Subject: [PATCH 37/37] Added homework exercises --- .../mandatory/3-dog-photo-gallery/index.html | 45 +++++++++++++++++++ .../mandatory/4-programmer-humour/index.html | 15 +++++++ .../mandatory/4-programmer-humour/script.js | 10 +++++ .../mandatory/4-programmer-humour/style.css | 0 4 files changed, 70 insertions(+) create mode 100644 week-8/Homework/mandatory/3-dog-photo-gallery/index.html create mode 100644 week-8/Homework/mandatory/4-programmer-humour/index.html create mode 100644 week-8/Homework/mandatory/4-programmer-humour/script.js create mode 100644 week-8/Homework/mandatory/4-programmer-humour/style.css diff --git a/week-8/Homework/mandatory/3-dog-photo-gallery/index.html b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html new file mode 100644 index 000000000..c4431f5d6 --- /dev/null +++ b/week-8/Homework/mandatory/3-dog-photo-gallery/index.html @@ -0,0 +1,45 @@ + + + + + + Dog photo gallery + + + + + + + +
    + + + + diff --git a/week-8/Homework/mandatory/4-programmer-humour/index.html b/week-8/Homework/mandatory/4-programmer-humour/index.html new file mode 100644 index 000000000..cede82e83 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/index.html @@ -0,0 +1,15 @@ + + + + + + Dog photo gallery + + + + + + Some photo + + + diff --git a/week-8/Homework/mandatory/4-programmer-humour/script.js b/week-8/Homework/mandatory/4-programmer-humour/script.js new file mode 100644 index 000000000..a1bc0fdd7 --- /dev/null +++ b/week-8/Homework/mandatory/4-programmer-humour/script.js @@ -0,0 +1,10 @@ +fetch("https://xkcd.now.sh/?comic=latest") + .then(function (result) { + return result.json(); + }) + + .then(function (humor) { + console.log(humor); + document.querySelector("#image").src = humor.img; + }) + .catch((error) => console.log(error)); diff --git a/week-8/Homework/mandatory/4-programmer-humour/style.css b/week-8/Homework/mandatory/4-programmer-humour/style.css new file mode 100644 index 000000000..e69de29bb