From 5721a5792fc38e248df77a457dd85a7bea12b639 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Sun, 20 Nov 2022 13:16:51 +0000 Subject: [PATCH 01/20] first attemtp at fixing errors --- mandatory/1-syntax-errors.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..cfd3eeecf 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}`; } /* @@ -30,9 +31,7 @@ test("addNumbers adds numbers correctly", () => { }); test("introduceMe function returns the correct string", () => { - expect(introduceMe("Sonjide", 27)).toEqual( - "Hello, my name is Sonjide and I am 27 years old" - ); + expect(introduceMe("Sonjide", 27)).toEqual("Hello, my name is Sonjide and I am 27 years old"); }); test("getTotal returns a string describing the total", () => { From ba3ade92a79cd318e66f5ae26e3dc2f8e7c45b5d Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Sun, 20 Nov 2022 15:42:19 +0000 Subject: [PATCH 02/20] madatory completed need to clean up --- mandatory/1-syntax-errors.js | 2 +- mandatory/2-logic-error.js | 11 ++++------- mandatory/3-function-output.js | 20 ++++++++++++++++++++ mandatory/4-tax.js | 32 +++++++++++++++++++++++++++++--- 4 files changed, 54 insertions(+), 11 deletions(-) diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index cfd3eeecf..4713b56b8 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -5,7 +5,7 @@ function addNumbers(a, b, c) { } function introduceMe(name, age) { - return "Hello, my name is " + `${name}` + " and I am "`${age}` + " years old"; + return "Hello, my name is " + `${name}` + " and I am " + `${age}` + " years old"; } function getTotal(a, b) { diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..3b05e536d 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 word.trim(); } function getStringLength(word) { - return "word".length(); + return word.length; } function multiply(a, b, c) { - a * b * c; - return; + return a * b * c; } /* @@ -29,9 +28,7 @@ test("trimWord trims leading and trailing whitespace", () => { }); test("trimWord doesn't remove whitespace in the middle of the string", () => { - expect(trimWord(" CodeYourFuture teaches coding ")).toEqual( - "CodeYourFuture teaches coding" - ); + expect(trimWord(" CodeYourFuture teaches coding ")).toEqual("CodeYourFuture teaches coding"); }); test("getStringLength returns the length of a word", () => { diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..9b32c5b15 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -1,9 +1,27 @@ // Add comments to explain what this function does. You're meant to use Google! + +// the function generates a random number between 0 and <1, +//the number is never equal to 1. times the nubmeer by 10 +//creates a random numbere between 0 and <10. +/* +google say : The Math.random() function returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1, with approximately uniform distribution over that range — which you can then scale to your desired range + +https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#:~:text=The%20Math.random()%20function,scale%20to%20your%20desired%20range. + */ function getRandomNumber() { return Math.random() * 10; } // Add comments to explain what this function does. You're meant to use Google! + +/* +the below function joins two words together as is, so if thier is no white space the words will be read as one. + +google= The concat() function concatenates the string arguments to the calling string and returns a new string. Changes to the original string or .. + +https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat +*/ + function combine2Words(word1, word2) { return word1.concat(word2); } @@ -11,8 +29,10 @@ function combine2Words(word1, word2) { 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 this function is expected to return. + return firstWord.concat(" ", secondWord, " ", thirdWord); } +console.log(concatenate("I", "am", 13)); /* =================================================== ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index ba77c7ae2..9a4c676eb 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -4,9 +4,29 @@ A business requires a program that calculates how much the price of a product is including sales tax Sales tax is 20% of the price of the product. */ +/* +// function does decimaal conversion and tax +function calculateSalesTax(price) { + //convert number to decimall place twin + let newPrice = price.toFixed(2); + //convert numb form string back to numb + let usePrice = newPrice * 1; + console.log(typeof usePrice); + console.log(usePrice); + let taxPrice = usePrice * 1.2; + let showPrice = taxPrice.toFixed(2); + console.log(showPrice); + return `£ ${showPrice}`; +} +calculateSalesTax(15); +*/ -function calculateSalesTax() {} - +function calculateSalesTax(price) { + let taxPrice = price * 1.2; + console.log(taxPrice); + return taxPrice; +} +calculateSalesTax(34); /* CURRENCY FORMATTING =================== @@ -17,8 +37,14 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(price_tax) { + let newPrice = calculateSalesTax(price_tax); + let showPrice = newPrice.toFixed(2); + console.log(showPrice); + return `£${showPrice}`; +} +addTaxAndFormatCurrency(17.5); /* =================================================== ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== From 2a8b19c29943c05c17d7395a02737d77eba31a60 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Mon, 21 Nov 2022 22:23:03 +0000 Subject: [PATCH 03/20] completed first extra --- exercises/B-hello-world/exercise.js | 2 ++ exercises/C-variables/exercise.js | 4 +++- extra/1-currency-conversion.js | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js index b179ee953..1b9c1894a 100644 --- a/exercises/B-hello-world/exercise.js +++ b/exercises/B-hello-world/exercise.js @@ -1 +1,3 @@ console.log("Hello world"); +console.log("Hello world", "hellos"); +console.log(5, 5); diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..a17507f15 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `greeting` - +let greeting = "Hello World"; +console.log(greeting); +console.log(greeting); console.log(greeting); diff --git a/extra/1-currency-conversion.js b/extra/1-currency-conversion.js index 75b3c6aab..4d6c4f8be 100644 --- a/extra/1-currency-conversion.js +++ b/extra/1-currency-conversion.js @@ -5,7 +5,11 @@ Write a function that converts a price to USD (exchange rate is 1.4 $ to £) */ -function convertToUSD() {} +function convertToUSD(pound) { + let dollar = pound * 1.4; + console.log(dollar); + return dollar; +} /* CURRENCY CONVERSION @@ -15,8 +19,16 @@ function convertToUSD() {} They have also decided that they should add a 1% fee to all foreign transactions, which means you only convert 99% of the £ to BRL. */ -function convertToBRL() {} +function convertToBRL(pound) { + let bRail = pound * 5.7; + console.log(bRail); + let railAndFee = bRail * 0.99; + console.log(railAndFee); + return railAndFee.toFixed(2) * 1; +} +console.log(convertToBRL(30)); +console.log(convertToUSD(32)); /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. From 7437ea20d9246230cb7f03c9c1997e9e5bf88b2f Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:33:28 +0000 Subject: [PATCH 04/20] Update exercise.js added a message variable --- exercises/D-strings/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 2cffa6a81..a5334e627 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,3 @@ // Start by creating a variable `message` - +let message = "good morning"; console.log(message); From c33628848ccc4dc1d86d0e8cf21c7cd0789dc656 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:35:17 +0000 Subject: [PATCH 05/20] Update exercise.js --- exercises/D-strings/exercise.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index a5334e627..4d4c5ffab 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `message` let message = "good morning"; +let stringType = typeOf message; console.log(message); +console.log(messageType); From 7fde69f06dd96d1ff4d7e7d6bb8180e704dbff3e Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:35:53 +0000 Subject: [PATCH 06/20] Update exercise.js --- exercises/D-strings/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 4d4c5ffab..94f9f7047 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,5 +1,5 @@ // Start by creating a variable `message` let message = "good morning"; -let stringType = typeOf message; +let stringType = typeof message; console.log(message); console.log(messageType); From ec298c3cc633533795d0180c5311d8cba782dca5 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:50:47 +0000 Subject: [PATCH 07/20] Update exercise.js --- exercises/E-strings-concatenation/exercise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..a59b2a263 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `message` - +let greeting = "Hello"; +let name = "olus"; +let message = greet + " " + name; console.log(message); From ca8264c875ebea66fdd78580618cba3781f8612d Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:52:24 +0000 Subject: [PATCH 08/20] Update exercise.js --- exercises/E-strings-concatenation/exercise.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index a59b2a263..8af70eba4 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` -let greeting = "Hello"; +let greeting = "Hello my name is"; let name = "olus"; -let message = greet + " " + name; +let message = greeting + " " + name; console.log(message); From 4c6b72292ee0f3ea0c82138b6c85bdd8979f26fa Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 17:56:14 +0000 Subject: [PATCH 09/20] Update exercise.js --- exercises/F-strings-methods/exercise.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..133c50ea6 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,3 +1,5 @@ // Start by creating a variable `message` - +let name = "olus" +let nameLength = name.length; +let message = `my name is ${name} and my name is ${nameLength} long`; console.log(message); From 69f6adbe0af0dc6396b120825d22ca67d38865a5 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:02:15 +0000 Subject: [PATCH 10/20] Update exercise2.js --- exercises/F-strings-methods/exercise2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..5ff7003bb 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,4 @@ const name = " Daniel "; - +let pName = name.trim(); +let messgae = `my name is ${pName} and my name is ${pName.length} characters long`; console.log(message); From fdbd2f0851355ceb2b697d15e5949202531f2fd9 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:05:32 +0000 Subject: [PATCH 11/20] Update exercise.js --- exercises/G-numbers/exercise.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..9faa2545a 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,4 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` +let numberOfStudents = 15 +let numberOfMentors = 8 +let message = ` Total number of students and mentors: ${numberOfStudents + numberOfMentors}`; From 5df43b7a5ff5fef8b7b569fe6b8e081b6d9285dd Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:19:27 +0000 Subject: [PATCH 12/20] Update exercise.js --- exercises/I-floats/exercise.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..5ce139072 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,12 @@ -var numberOfStudents = 15; -var numberOfMentors = 8; +let numberOfStudents = 15; +let numberOfMentors = 8; +let sum = (numberOfStudents + numberOfMentors); + +let percentage = function percent(val, total){ + return (Math.round(val / total) * 100 ); +} + +let perOfStud = percentage(numberOfStudents, sum); +let perOfMent = percentage(numberOfMentors, sum); +console.log(`Percentage students: ${perOfStud}`); +console.log(`Percentage Mentors: ${perOfMent}`); From deacb9f0803c7799ef2113b7242020e7688c20e0 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:21:31 +0000 Subject: [PATCH 13/20] Update exercise.js --- exercises/J-functions/exercise.js | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/J-functions/exercise.js b/exercises/J-functions/exercise.js index 0ae5850e5..0fc4c3655 100644 --- a/exercises/J-functions/exercise.js +++ b/exercises/J-functions/exercise.js @@ -1,5 +1,6 @@ function halve(number) { // complete the function here + return number / 2; } var result = halve(12); From 6765c36b957e3eecf3add0fbd64d71c9a655beb3 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:22:18 +0000 Subject: [PATCH 14/20] Update exercise2.js --- exercises/J-functions/exercise2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/J-functions/exercise2.js b/exercises/J-functions/exercise2.js index 82ef5e780..468d45596 100644 --- a/exercises/J-functions/exercise2.js +++ b/exercises/J-functions/exercise2.js @@ -1,5 +1,6 @@ function triple(number) { // complete function here + return number * 3; } var result = triple(12); From 0b0c429e5bd505f239ff3f3c93cd92e0849546d8 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:23:48 +0000 Subject: [PATCH 15/20] Update exercise.js --- exercises/K-functions-parameters/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/K-functions-parameters/exercise.js b/exercises/K-functions-parameters/exercise.js index 8d5db5e69..3c13ee270 100644 --- a/exercises/K-functions-parameters/exercise.js +++ b/exercises/K-functions-parameters/exercise.js @@ -1,6 +1,7 @@ // Complete the function so that it takes input parameters -function multiply() { +function multiply( a, b) { // Calculate the result of the function and return it + return a * b; } // Assign the result of calling the function the variable `result` From 343e6ced107215d3296676559d369581c02382dc Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:24:43 +0000 Subject: [PATCH 16/20] Update exercise2.js --- exercises/K-functions-parameters/exercise2.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exercises/K-functions-parameters/exercise2.js b/exercises/K-functions-parameters/exercise2.js index db7a8904b..8ff30c5d2 100644 --- a/exercises/K-functions-parameters/exercise2.js +++ b/exercises/K-functions-parameters/exercise2.js @@ -1,4 +1,7 @@ // Declare your function first +function divide(a, b){ + return a / b; +} var result = divide(3, 4); From 2d471f9b72b54afd086320e4929c94301b006ddd Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:27:02 +0000 Subject: [PATCH 17/20] Update exercise3.js --- exercises/K-functions-parameters/exercise3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exercises/K-functions-parameters/exercise3.js b/exercises/K-functions-parameters/exercise3.js index 537e9f4ec..599a86ef3 100644 --- a/exercises/K-functions-parameters/exercise3.js +++ b/exercises/K-functions-parameters/exercise3.js @@ -1,5 +1,9 @@ // Write your function here +function createGreeting(name){ +return `Hello, my name is ${name}` +} + var greeting = createGreeting("Daniel"); console.log(greeting); From 87dc4a05b6c61cd37d4c63e0d434a7a6938a3a03 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:31:25 +0000 Subject: [PATCH 18/20] Update exercise4.js --- exercises/K-functions-parameters/exercise4.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exercises/K-functions-parameters/exercise4.js b/exercises/K-functions-parameters/exercise4.js index 7ab44589e..f0ae24f68 100644 --- a/exercises/K-functions-parameters/exercise4.js +++ b/exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,8 @@ // Declare your function first - +function addNumb( a, b ){ +return a + b; +} +let sum = addNumb(13, 124); // Call the function and assign to a variable `sum` console.log(sum); From 40be8d302ceeb7649466e74ccec9a05080c8753a Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:33:59 +0000 Subject: [PATCH 19/20] Update exercise5.js --- exercises/K-functions-parameters/exercise5.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exercises/K-functions-parameters/exercise5.js b/exercises/K-functions-parameters/exercise5.js index 7c5bcd605..d684eb707 100644 --- a/exercises/K-functions-parameters/exercise5.js +++ b/exercises/K-functions-parameters/exercise5.js @@ -1,4 +1,7 @@ // Declare your function here +function createLongGreeting(name, number){ +return `Hello, my name is ${name} and I'm ${number} years old` +} const greeting = createLongGreeting("Daniel", 30); From 72c0c8987ec8d2c6ad1554a8fa6df6d341866448 Mon Sep 17 00:00:00 2001 From: OlushoreOdude <108965036+OlushoreOdude@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:48:10 +0000 Subject: [PATCH 20/20] Update exercise.js --- exercises/L-functions-nested/exercise.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js index a5d377442..a68bbb6d4 100644 --- a/exercises/L-functions-nested/exercise.js +++ b/exercises/L-functions-nested/exercise.js @@ -3,3 +3,21 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; + + +let capL = function capitalLetter(name) { + //let pName = this.name; + return name.toUpperCase(); +} + +function greeting(name) { + let shout = capL(name); + return ` HELLO ${shout}` + //return ` HELLO MY NAME IS ${capL(name)}` +} + +console.log(greeting(mentor1)); +console.log(greeting(mentor2)); +console.log(greeting(mentor3)); +console.log(greeting(mentor4)); +console.log(greeting(mentor5));