From 734bbf233940046ed4015811b1c242ee291f9350 Mon Sep 17 00:00:00 2001 From: "Hengameh M.Khani" <108895187+HeniMKH@users.noreply.github.com> Date: Wed, 23 Nov 2022 20:30:37 +0000 Subject: [PATCH 1/3] half --- mandatory/1-syntax-errors.js | 13 +++++++------ mandatory/2-logic-error.js | 7 +++---- mandatory/4-tax.js | 6 +++++- package.json | 12 +++++++++--- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..f9b62a5dd 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,20 +1,21 @@ // 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; } /* -=================================================== +=================================================== ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== There are some Tests in this file that will help you work out if your code is working. diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..ff0fd642f 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; } /* diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index ba77c7ae2..7f5b0e9ef 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -5,7 +5,11 @@ Sales tax is 20% of the price of the product. */ -function calculateSalesTax() {} +function calculateSalesTax(price) { + const priceWithTax =1.2* price; +return priceWithTax; +} + /* CURRENCY FORMATTING 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 b0b5156d487792b0946eb9a3a43c71c20d62c1e4 Mon Sep 17 00:00:00 2001 From: "Hengameh M.Khani" <108895187+HeniMKH@users.noreply.github.com> Date: Thu, 24 Nov 2022 23:55:19 +0000 Subject: [PATCH 2/3] mandatory done --- exercises/B-hello-world/exercise.js | 4 +++- exercises/C-variables/exercise.js | 1 + exercises/D-strings/exercise.js | 2 +- exercises/E-strings-concatenation/exercise.js | 5 +++-- mandatory/1-syntax-errors.js | 5 +++-- mandatory/2-logic-error.js | 4 ++-- mandatory/3-function-output.js | 5 ++++- mandatory/4-tax.js | 4 +++- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js index b179ee953..e54bc4e7e 100644 --- a/exercises/B-hello-world/exercise.js +++ b/exercises/B-hello-world/exercise.js @@ -1 +1,3 @@ -console.log("Hello world"); +let greeting = ("Hello world"); +console.log("greeting"); + diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..0e0bda4d4 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,4 @@ // Start by creating a variable `greeting` console.log(greeting); +console.log("Heni") diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 2cffa6a81..46d27bf0e 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 ="This is a message"; console.log(message); diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..edbd82148 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` - -console.log(message); +var greetingStart = "Hello, my name is "; +var name = "Daniel"; +console.log(greeting); diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index f9b62a5dd..4494cb55a 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -5,11 +5,12 @@ 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) { - total = a + b; + let total = a + b; return "The total is " + total; } diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index ff0fd642f..995910d8d 100644 --- a/mandatory/2-logic-error.js +++ b/mandatory/2-logic-error.js @@ -1,11 +1,11 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return trimWord; + return word.trim(); } function getStringLength(word) { - return "word".length; + return word.length; } function multiply(a, b, c) { diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..e002b0263 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -9,7 +9,10 @@ function combine2Words(word1, word2) { } function concatenate(firstWord, secondWord, thirdWord) { - // Write the body of this function to concatenate three words together. + let result = firstWord.concat(" "+ secondWord + " " +thirdWord); + + return result + // 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. } diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index 7f5b0e9ef..df73390a7 100644 --- a/mandatory/4-tax.js +++ b/mandatory/4-tax.js @@ -21,7 +21,9 @@ return priceWithTax; Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(productPrice) { + return "£" +(calculateSalesTax(productPrice)).toFixed(2) +} /* =================================================== From 29eec064d76607115ce8b60e7e37639b98b0b8ab Mon Sep 17 00:00:00 2001 From: "Hengameh M.Khani" <108895187+HeniMKH@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:52:22 +0000 Subject: [PATCH 3/3] excersize --- exercises/C-variables/exercise.js | 5 +++-- exercises/D-strings/exercise.js | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index 0e0bda4d4..93a9d128b 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,4 +1,5 @@ // Start by creating a variable `greeting` - +var greeting="Hello world"; +console.log(greeting); +console.log(greeting); console.log(greeting); -console.log("Heni") diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 46d27bf0e..0aa2a3035 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,6 @@ // Start by creating a variable `message` -let message ="This is a message"; -console.log(message); +let message ="This is a string"; + console.log (message) +console.log(typeof message); + +