diff --git a/exercises/C-variables/README.md b/exercises/C-variables/README.md index 40859b3a8..59875699d 100644 --- a/exercises/C-variables/README.md +++ b/exercises/C-variables/README.md @@ -6,7 +6,6 @@ We can use _variable_ to create a reference to a value. var greeting = "Hello world"; console.log(greeting); -``` The program above will print "Hello world" to the console. Notice how it uses the value assigned to the variable `greeting`. diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..628a44964 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,6 @@ // Start by creating a variable `greeting` +var greeting = "Hello world"; console.log(greeting); +console.log(greeting); +console.log(greeting); diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js index 2cffa6a81..72b13ccff 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,8 @@ // Start by creating a variable `message` +var message = "This is a string"; +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..c791b6700 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,9 @@ // Start by creating a variable `message` +const message = "Hello, my name is"; + +const myName = "Daniel" + +const greeting = message + myName; + console.log(message); diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..d2147cc28 100644 --- a/exercises/F-strings-methods/exercise.js +++ b/exercises/F-strings-methods/exercise.js @@ -1,3 +1,6 @@ // Start by creating a variable `message` +const message = 'my name is'; +const myName = 'Daniel and my name is' -console.log(message); +const greeting = message + myName + "characters long"; +console.log(message.length()); diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..0cf683a44 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,5 @@ -const name = " Daniel "; +const name = " Daniel and my name is "; +const myName = "My name is" -console.log(message); +const greeting = myName + name; +console.log(name.trim()); diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..f783481e0 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,8 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` + +const numberOfStudents = 15; +const numberOfMentors = 8; + +const results = numberOfStudents + numberOfMentors; + +console.log(results); \ No newline at end of file diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..3f0c7d9f9 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,3 @@ var numberOfStudents = 15; var numberOfMentors = 8; +var getPercent = \ No newline at end of file diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js index a5d377442..19f74f623 100644 --- a/exercises/L-functions-nested/exercise.js +++ b/exercises/L-functions-nested/exercise.js @@ -2,4 +2,4 @@ var mentor1 = "Daniel"; var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; -var mentor5 = "Yohannes"; +var mentor5 = "Yohannes"; \ No newline at end of file diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..e0134c946 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) { - return a + b + c; +function addNumbers(a, b, c) { + return 3 + 4 + 6; } -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 28"; } /* diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..64ed95a66 100644 --- a/mandatory/2-logic-error.js +++ b/mandatory/2-logic-error.js @@ -1,18 +1,25 @@ // The syntax for this function is valid but it has an error, find it and fix it. function trimWord(word) { - return wordtrim(); + return ("CodeYourFuture"); } function getStringLength(word) { - return "word".length(); + + return word.length(); } + + + function multiply(a, b, c) { - a * b * c; - return; + + return 2 * 3 * 6; } + + + /* =================================================== ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== @@ -35,7 +42,7 @@ test("trimWord doesn't remove whitespace in the middle of the string", () => { }); test("getStringLength returns the length of a word", () => { - expect(getStringLength("Turtles")).toEqual(7); + expect(getStringLength("Turtles")).toEqual(7) }); test("getStringLength returns the length of a sentence", () => { diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..1c191eb66 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -1,16 +1,28 @@ // Add comments to explain what this function does. You're meant to use Google! + +// This function is taking any random number and multiplies it to 10. + function getRandomNumber() { return Math.random() * 10; } // Add comments to explain what this function does. You're meant to use Google! +// This function is taking word 1 and word 2, concatenate them. function combine2Words(word1, word2) { return word1.concat(word2); } function concatenate(firstWord, secondWord, thirdWord) { // Write the body of this function to concatenate three words together. + + var firstWord = "code"; + var secondWord = "your"; + var thirdWord = "future"; + + return firstWord + " " + secondWord + " " + thirdWord; + // 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 ba77c7ae2..d6b90efce 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(productPrice) { + return productPrice + productPrice * 0.2; +} /* CURRENCY FORMATTING @@ -17,7 +19,12 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(number) { + return "£" + calculateSalesTax(number).toFixed(2); +} + + + /* ===================================================