From 68f697645a4e347992f71f394670f10c6f780018 Mon Sep 17 00:00:00 2001 From: BereniceOgundele <102852581+BereniceOgundele@users.noreply.github.com> Date: Sun, 3 Jul 2022 19:15:30 +0200 Subject: [PATCH 1/5] completed exercises B - F Completed exercises B to F --- exercises/B-hello-world/exercise.js | 3 +++ exercises/C-variables/exercise.js | 4 +++- exercises/D-strings/README.md | 2 ++ exercises/D-strings/exercise.js | 5 ++++- exercises/E-strings-concatenation/exercise.js | 6 +++++- exercises/F-strings-methods/exercise.js | 8 +++++++- exercises/F-strings-methods/exercise2.js | 1 + package.json | 12 +++++++++--- 8 files changed, 34 insertions(+), 7 deletions(-) diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js index b179ee953..13c6e9ce9 100644 --- a/exercises/B-hello-world/exercise.js +++ b/exercises/B-hello-world/exercise.js @@ -1 +1,4 @@ console.log("Hello world"); +console.log("Hello World.", "I just started learning JavaScript", "I am very new at this, Lets see if this worked"); +// console.log(I am very new at this); +console.log(5); \ No newline at end of file diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..d05d92350 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `greeting` - +var greeting = "Hi there"; +console.log(greeting); +console.log(greeting); console.log(greeting); diff --git a/exercises/D-strings/README.md b/exercises/D-strings/README.md index fd0a664ae..049990156 100644 --- a/exercises/D-strings/README.md +++ b/exercises/D-strings/README.md @@ -2,6 +2,7 @@ In programming there are different _types of_ data. You've used one data type al Computers recognise strings as a sequence of characters but to humans, strings are simply lines of text. + ```js var message = "This is a string"; ``` @@ -17,6 +18,7 @@ var messageType = typeof message; console.log(messageType); // logs 'string' ``` + ## Exercise - Write a program that logs a message and its type diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 2cffa6a81..fc8e7b190 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,6 @@ // Start by creating a variable `message` +var message = "This is a string exercise"; +var messageType = typeof message; + +console.log(messageType); -console.log(message); diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..39aa9c18a 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,7 @@ // Start by creating a variable `message` +var greetingStart = "Hello, my name is"; +var myName = "Berenice"; -console.log(message); +var greeting = greetingStart + myName; + +console.log(greeting); diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..5a87eac44 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,3 +1,9 @@ // Start by creating a variable `message` -console.log(message); +var str = "Daniel"; +var nameLength = nameLength; + +console.log(nameLength); + +var str = ' My name is Daniel and my name is 6 characters long '; +console.log(str.trim()); \ No newline at end of file diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..2b0e48094 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,4 @@ const name = " Daniel "; +var str = ' My name is daniel and my name is 6 characters long ' console.log(message); diff --git a/package.json b/package.json index 93e0861e3..9e7f2ffeb 100644 --- a/package.json +++ b/package.json @@ -14,15 +14,21 @@ "url": "https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1/issues" }, "jest": { - "setupFilesAfterEnv": ["jest-extended"], + "setupFilesAfterEnv": [ + "jest-extended" + ], "projects": [ { "displayName": "mandatory", - "testMatch": ["/mandatory/*.js"] + "testMatch": [ + "/mandatory/*.js" + ] }, { "displayName": "extra", - "testMatch": ["/extra/*.js"] + "testMatch": [ + "/extra/*.js" + ] } ] }, From 1d282cfb3ec4976223cb320af6ade56ea8a55aa5 Mon Sep 17 00:00:00 2001 From: BereniceOgundele <102852581+BereniceOgundele@users.noreply.github.com> Date: Sun, 3 Jul 2022 21:09:55 +0200 Subject: [PATCH 2/5] completed x1 mandatory exercise I attempted X1 mandatory exercise to see if the test passed and it did --- exercises/E-strings-concatenation/exercise.js | 2 +- exercises/F-strings-methods/exercise2.js | 3 ++- mandatory/1-syntax-errors.js | 11 ++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 39aa9c18a..f241de40f 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,5 +1,5 @@ // Start by creating a variable `message` -var greetingStart = "Hello, my name is"; +var greetingStart = "Hello, my name is "; var myName = "Berenice"; var greeting = greetingStart + myName; diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index 2b0e48094..e50c5fc78 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,4 +1,5 @@ const name = " Daniel "; +const message = name.trim(); -var str = ' My name is daniel and my name is 6 characters long ' console.log(message); +//was not sure if i should combine the X2 exercises \ No newline at end of file diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..98360ac6b 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,16 +1,17 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(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 getTotal(a, b) { - total = a ++ b; + total = a + b; - return "The total is total"; + return "The total is " + total; } /* From 24a5de54b9d56417cd3adad552dd986c2185f47a Mon Sep 17 00:00:00 2001 From: BereniceOgundele <102852581+BereniceOgundele@users.noreply.github.com> Date: Tue, 2 Aug 2022 21:01:49 +0200 Subject: [PATCH 3/5] Exercises B to I (node) I finally got these exercises to run correctly in Node!!! --- .vscode/settings.json | 4 ++++ exercises/F-strings-methods/exercise.js | 2 +- exercises/G-numbers/exercise.js | 5 +++++ exercises/I-floats/exercise.js | 9 +++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..fe5bd20a6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.formatOnSave": true, + "editor.formatOnPaste": true +} \ No newline at end of file diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 5a87eac44..fbca63543 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -5,5 +5,5 @@ var nameLength = nameLength; console.log(nameLength); -var str = ' My name is Daniel and my name is 6 characters long '; +var str = " My name is Daniel and my name is 6 characters long "; console.log(str.trim()); \ No newline at end of file diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..54357eb3a 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,6 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` + +let numberOfStudents = 15; +let numberOfMentors = 8; + +console.log(numberOfStudents + numberOfMentors); \ No newline at end of file diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..2ac1228f3 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,7 @@ -var numberOfStudents = 15; -var numberOfMentors = 8; +var numberOfStudents = 15 / 23; +var percentagePerGroup = Math.round(numberOfStudents); +console.log(numberOfStudents); + +var numberOfMentors = 8 / 23; +var percentagePerGroup = Math.round(numberOfMentors) +console.log(numberOfMentors); \ No newline at end of file From 304da507afbaa47df562878c19ab08d0f3b8927a Mon Sep 17 00:00:00 2001 From: BereniceOgundele <102852581+BereniceOgundele@users.noreply.github.com> Date: Wed, 3 Aug 2022 22:14:45 +0200 Subject: [PATCH 4/5] mandatory worked on some mandatory exercises --- exercises/K-functions-parameters/exercise.js | 2 +- mandatory/3-function-output.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/exercises/K-functions-parameters/exercise.js b/exercises/K-functions-parameters/exercise.js index 8d5db5e69..c384cf675 100644 --- a/exercises/K-functions-parameters/exercise.js +++ b/exercises/K-functions-parameters/exercise.js @@ -1,5 +1,5 @@ // Complete the function so that it takes input parameters -function multiply() { +function multiply(num1, num2) { // Calculate the result of the function and return it } diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..5bb00a0da 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -2,13 +2,20 @@ function getRandomNumber() { return Math.random() * 10; } +//the function will get numbers between 1 and 10 and round it up or down // Add comments to explain what this function does. You're meant to use Google! function combine2Words(word1, word2) { return word1.concat(word2); } +// /two words will be combined to form a new word function concatenate(firstWord, secondWord, thirdWord) { + var one = "firstWord" + var two = "secondWord" + var three = "thirdWord" + + console.log(one + two + three); // Write the body of this function to concatenate three words together. // Look at the test case below to understand what this function is expected to return. } From a0b687801bbf24d7f3b0e5bdc589cc37ed52b18d Mon Sep 17 00:00:00 2001 From: BereniceOgundele <102852581+BereniceOgundele@users.noreply.github.com> Date: Thu, 15 Sep 2022 04:09:01 +0200 Subject: [PATCH 5/5] worked on exercises and mandatory I worked on the above and am ready to commit these changes --- exercises/F-strings-methods/README.md | 5 +---- exercises/F-strings-methods/exercise.js | 10 ++++------ exercises/F-strings-methods/exercise2.js | 21 +++++++++++++++++---- mandatory/2-logic-error.js | 7 +++---- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/exercises/F-strings-methods/README.md b/exercises/F-strings-methods/README.md index fb07ec8ef..e6b2e443a 100644 --- a/exercises/F-strings-methods/README.md +++ b/exercises/F-strings-methods/README.md @@ -10,10 +10,7 @@ console.log(nameLength); // Logs 6 You can also get a modified version of a string by calling _string methods_. Let's try one: ```js -var name = "Daniel"; -var nameLowerCase = name.toLowerCase(); - -console.log(nameLowerCase); // "daniel" +"" // "daniel" ``` You can find out more about string properties and methods by searching for "JavaScript string methods". diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index fbca63543..369f7e5fe 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,9 +1,7 @@ // Start by creating a variable `message` -var str = "Daniel"; -var nameLength = nameLength; +const greetingStart = "My name is "; +const myName = "Daniel" +const namePlusLength = " and my name is 6 characters long" -console.log(nameLength); - -var str = " My name is Daniel and my name is 6 characters long "; -console.log(str.trim()); \ No newline at end of file +console.log(greetingStart + myName + namePlusLength); \ No newline at end of file diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index e50c5fc78..b7c3da5c4 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,5 +1,18 @@ -const name = " Daniel "; -const message = name.trim(); +const greetingStart = "My name is "; +const myName = " Daniel " +const namePlusLength = " and my name is 6 characters long" +const message = myName.trim(); -console.log(message); -//was not sure if i should combine the X2 exercises \ No newline at end of file +console.log(myName.trim()); + + + + + + + +// const name = " Daniel "; +// const message = name.trim(); + +// console.log(message); +// //was not sure if i should combine the X2 exercises \ No newline at end of file diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..96e7e515e 100644 --- a/mandatory/2-logic-error.js +++ b/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 trimWord(); } function getStringLength(word) { - return "word".length(); + return word.length(); } function multiply(a, b, c) { - a * b * c; - return; + return a + b + c; } /*