From 3e2d12bc0c31c7b3cb75ce9bcf96e44c7af0fa74 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Tue, 2 Aug 2022 22:29:58 +0100 Subject: [PATCH 01/16] Update exercise.js --- exercises/E-strings-concatenation/exercise.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..2221c2dba 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,4 @@ -// Start by creating a variable `message` +let greetingStart = "Hello my name is "; +let firstName = "Rabie "; -console.log(message); +console.log(greetingStart + firstName); From 0d98f2fa26bd50719c9c3c81f78abf4d0dce41b3 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Tue, 2 Aug 2022 22:33:11 +0100 Subject: [PATCH 02/16] Update exercise.js --- exercises/F-strings-methods/exercise.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..1cbce498f 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` +var name = "Rabie"; +var nameLnegth = name.length; -console.log(message); +console.log(nameLnegth); +console.log(name.length); From c86ec2a851e02818662b55184ee29b373aac04dd Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Tue, 2 Aug 2022 23:00:52 +0100 Subject: [PATCH 03/16] Update exercise.js --- exercises/F-strings-methods/exercise.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 1cbce498f..d4bb67235 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,5 +1,11 @@ -var name = "Rabie"; -var nameLnegth = name.length; +let firstMessage = "Hello my name is "; +let secondmessage = "and my name is "; +let thirdmessage = " long"; +let name = "Rabie "; +let length = name.length; -console.log(nameLnegth); -console.log(name.length); + +let message = firstMessage + name + secondmessage + length + thirdmessage; + + +console.log(message); From e9ae492df69f61928cd60747da531d687e427810 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Tue, 2 Aug 2022 23:02:09 +0100 Subject: [PATCH 04/16] Update exercise2.js --- exercises/F-strings-methods/exercise2.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..d4bb67235 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,11 @@ -const name = " Daniel "; +let firstMessage = "Hello my name is "; +let secondmessage = "and my name is "; +let thirdmessage = " long"; +let name = "Rabie "; +let length = name.length; + + +let message = firstMessage + name + secondmessage + length + thirdmessage; + console.log(message); From 9360764c6ecb8dc8d9a8aac4e2c336ca1ba98b32 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Tue, 2 Aug 2022 23:07:16 +0100 Subject: [PATCH 05/16] Update exercise.js --- exercises/G-numbers/exercise.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..129797002 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,7 @@ -// Start by creating a variables `numberOfStudents` and `numberOfMentors` +let numOfStudents = 15; +let numOfmentores = 8; +let total = numOfStudents + numOfmentores; + +console.log("Number of student: " + numOfStudents); +console.log("Number of mentores: " + numOfmentores); +console.log("Total number of students and mentores " + total); From fddb62f9f0be95a4e5c2713761330972a9ad28a1 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Tue, 2 Aug 2022 23:38:14 +0100 Subject: [PATCH 06/16] Update exercise.js --- exercises/I-floats/exercise.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..9af54fea6 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,9 @@ -var numberOfStudents = 15; -var numberOfMentors = 8; +let numOfStudents = 15; +let numOfmentores = 8; +let total = numOfStudents + numOfmentores; + +let percentageOfStudents = (numOfStudents / total) * 100; +let percentageOfMentores = (numOfmentores / total) * 100; + +console.log("Percentage Students: " + Math.round(percentageOfStudents) + "%"); +console.log("Percentage Mentores: " + Math.round (percentageOfMentores) + "%"); From a8c295857353164ff7f622d13dd1b4f430799bed Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 00:03:41 +0100 Subject: [PATCH 07/16] Update exercise.js --- exercises/J-functions/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/J-functions/exercise.js b/exercises/J-functions/exercise.js index 0ae5850e5..d5b9b5740 100644 --- a/exercises/J-functions/exercise.js +++ b/exercises/J-functions/exercise.js @@ -1,7 +1,8 @@ function halve(number) { - // complete the function here + return number/2; } var result = halve(12); console.log(result); + From f3900ef334275ad4dac76329537fec3f2ec1957a Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 00:28:27 +0100 Subject: [PATCH 08/16] Update exercise2.js --- exercises/J-functions/exercise2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/J-functions/exercise2.js b/exercises/J-functions/exercise2.js index 82ef5e780..ca499a8ab 100644 --- a/exercises/J-functions/exercise2.js +++ b/exercises/J-functions/exercise2.js @@ -1,5 +1,5 @@ function triple(number) { - // complete function here + return number * 3; } var result = triple(12); From de49de2085fce71625eb55495d1cb3da726ed47b Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 00:32:18 +0100 Subject: [PATCH 09/16] Update exercise.js --- exercises/K-functions-parameters/exercise.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/exercises/K-functions-parameters/exercise.js b/exercises/K-functions-parameters/exercise.js index 8d5db5e69..9ccf2952a 100644 --- a/exercises/K-functions-parameters/exercise.js +++ b/exercises/K-functions-parameters/exercise.js @@ -1,9 +1,7 @@ -// Complete the function so that it takes input parameters -function multiply() { - // Calculate the result of the function and return it +function multiply(a, b){ + return a * b; } -// Assign the result of calling the function the variable `result` -var result = multiply(3, 4); +let result = multiply(5, 3); console.log(result); From f602ba2e39ec0514219edae176446b232b635aae Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 00:33:43 +0100 Subject: [PATCH 10/16] Update exercise2.js --- exercises/K-functions-parameters/exercise2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exercises/K-functions-parameters/exercise2.js b/exercises/K-functions-parameters/exercise2.js index db7a8904b..5d3d39c6f 100644 --- a/exercises/K-functions-parameters/exercise2.js +++ b/exercises/K-functions-parameters/exercise2.js @@ -1,5 +1,7 @@ -// Declare your function first +function divide(a, b){ + return a / b; +} -var result = divide(3, 4); +let result = divide(9, 3); console.log(result); From 897e82965f98b813361e520eb6e81a44e78e399d Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 14:33:31 +0100 Subject: [PATCH 11/16] Update exercise3.js --- exercises/K-functions-parameters/exercise3.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/K-functions-parameters/exercise3.js b/exercises/K-functions-parameters/exercise3.js index 537e9f4ec..f8cbe7fc1 100644 --- a/exercises/K-functions-parameters/exercise3.js +++ b/exercises/K-functions-parameters/exercise3.js @@ -1,5 +1,8 @@ -// Write your function here +function createGreeting (name){ + console.log("Hello, my name is " + name); + return name; +} -var greeting = createGreeting("Daniel"); +let greeting = createGreeting("Rabie"); console.log(greeting); From 5ff2530ff0e9b05756f1d204cba4a801f9f851c0 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 14:40:51 +0100 Subject: [PATCH 12/16] Update exercise4.js --- exercises/K-functions-parameters/exercise4.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/exercises/K-functions-parameters/exercise4.js b/exercises/K-functions-parameters/exercise4.js index 7ab44589e..48f3144ea 100644 --- a/exercises/K-functions-parameters/exercise4.js +++ b/exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,8 @@ -// Declare your function first +function summation(num1, num2){ + let sum = num1 + num2; + return sum +} -// Call the function and assign to a variable `sum` +let result = summation(13, 124); -console.log(sum); +console.log(result); From ce45bd103b04b7d66afda8034d17e22bcd482290 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Wed, 3 Aug 2022 15:01:12 +0100 Subject: [PATCH 13/16] Update exercise5.js --- exercises/K-functions-parameters/exercise5.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exercises/K-functions-parameters/exercise5.js b/exercises/K-functions-parameters/exercise5.js index 7c5bcd605..7a6a5f48e 100644 --- a/exercises/K-functions-parameters/exercise5.js +++ b/exercises/K-functions-parameters/exercise5.js @@ -1,5 +1,7 @@ -// Declare your function here +function greeting(name, age){ + let message = "Hello, my name is " + name + " and I am " + age + " years old"; + return message; +} -const greeting = createLongGreeting("Daniel", 30); - -console.log(greeting); +let greetingMessage = greeting("Rabie", 27); +console.log(greetingMessage); From c21554726d1df7042f855a6a43b2979601604916 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:53:28 +0100 Subject: [PATCH 14/16] Update 1-syntax-errors.js --- mandatory/1-syntax-errors.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..91987373f 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,14 +1,14 @@ // 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) { //There are missing "," between each argument. return 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"; // after name there needs to be + also after the string. function getTotal(a, b) { - total = a ++ b; + total = a ++ b; // why is there to + signs only one is needed, return "The total is total"; } From 2369a28753338911613d90def625c91681abe4f3 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali <70780557+AL-ASHMALI@users.noreply.github.com> Date: Thu, 4 Aug 2022 15:57:26 +0100 Subject: [PATCH 15/16] Update 2-logic-error.js --- mandatory/2-logic-error.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..4902d887d 100644 --- a/mandatory/2-logic-error.js +++ b/mandatory/2-logic-error.js @@ -1,16 +1,16 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return wordtrim(); // wordtrim is undefined word. } function getStringLength(word) { - return "word".length(); + return "word".length(); // word shouldn't be a string. } function multiply(a, b, c) { a * b * c; - return; + return; // the return should have the multiplication like: return a * b * c; } /* From 11000a86332ebac3bddd2b616ebabf2cbae0abf9 Mon Sep 17 00:00:00 2001 From: Rabie Al-Ashmali Date: Sat, 6 Aug 2022 16:40:11 +0100 Subject: [PATCH 16/16] all problems solved/Rabie al-ashmali --- mandatory/1-syntax-errors.js | 13 +++++++------ mandatory/2-logic-error.js | 8 ++++---- mandatory/3-function-output.js | 1 + mandatory/4-tax.js | 9 +++++++-- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index 91987373f..bd5b0e3f2 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,18 +1,19 @@ // There are syntax errors in this code - can you fix it to pass the tests? -function addNumbers(a b c) { //There are missing "," between each argument. +function addNumbers(a, b, c) { //There are missing "," between each argument. return a + b + c; } -function introduceMe(name, age) - return "Hello, my name is " + name "and I am " age + "years old"; // after name there needs to be + also after the string. - +function introduceMe(name, age){ + return "Hello, my name is " + name + " and I am " + age + " years old"; // after name there needs to be + also after the string. +} function getTotal(a, b) { - total = a ++ b; // why is there to + signs only one is needed, + let total = a + b; - return "The total is total"; + return "The total is " + total; } + /* =================================================== ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 4902d887d..82e864c5d 100644 --- a/mandatory/2-logic-error.js +++ b/mandatory/2-logic-error.js @@ -1,16 +1,16 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); // wordtrim is undefined word. + return word.trim(); // wordtrim is undefined word. } function getStringLength(word) { - return "word".length(); // word shouldn't be a string. + return word.length; // word shouldn't be a string. } function multiply(a, b, c) { - a * b * c; - return; // the return should have the multiplication like: return a * b * c; + + return a * b * c; // the return should have the multiplication like: return a * b * c; } /* diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..299307741 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -11,6 +11,7 @@ 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 + " " + secondWord + " " + thirdWord; } /* diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index ba77c7ae2..d488aa012 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -5,7 +5,9 @@ Sales tax is 20% of the price of the product. */ -function calculateSalesTax() {} +function calculateSalesTax(priceBeforeTax) { + return priceBeforeTax + (priceBeforeTax * 0.2); +} /* CURRENCY FORMATTING @@ -17,7 +19,10 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(priceBeforeTax) { + let priceAfterTax = calculateSalesTax(priceBeforeTax); + return `£${priceAfterTax.toFixed(2)}`; +} /* ===================================================