diff --git a/exercises/A-setup-ide/README.md b/.github/exercises/A-setup-ide/README.md similarity index 100% rename from exercises/A-setup-ide/README.md rename to .github/exercises/A-setup-ide/README.md diff --git a/exercises/B-hello-world/README.md b/.github/exercises/B-hello-world/README.md similarity index 100% rename from exercises/B-hello-world/README.md rename to .github/exercises/B-hello-world/README.md diff --git a/.github/exercises/B-hello-world/exercise.js b/.github/exercises/B-hello-world/exercise.js new file mode 100644 index 000000000..dd188f681 --- /dev/null +++ b/.github/exercises/B-hello-world/exercise.js @@ -0,0 +1,4 @@ +console.log("Hello world"); +console.log("this is my introduction to javascript") +console.log("by the end of javascript i will be experience in this programming language") + diff --git a/exercises/C-variables/README.md b/.github/exercises/C-variables/README.md similarity index 100% rename from exercises/C-variables/README.md rename to .github/exercises/C-variables/README.md diff --git a/.github/exercises/C-variables/exercise.js b/.github/exercises/C-variables/exercise.js new file mode 100644 index 000000000..aebbb46b6 --- /dev/null +++ b/.github/exercises/C-variables/exercise.js @@ -0,0 +1,5 @@ +// Start by creating a variable `greeting` +let greeting ="Hello world"; +console.log(greeting); +console.log(greeting); +console.log(greeting); diff --git a/exercises/D-strings/README.md b/.github/exercises/D-strings/README.md similarity index 100% rename from exercises/D-strings/README.md rename to .github/exercises/D-strings/README.md diff --git a/.github/exercises/D-strings/exercise.js b/.github/exercises/D-strings/exercise.js new file mode 100644 index 000000000..0fb126d1f --- /dev/null +++ b/.github/exercises/D-strings/exercise.js @@ -0,0 +1,7 @@ +// Start by creating a variable `message` +let message = "This is a string"; +let messageExample = typeof message; + + +console.log(message); +console.log(messageExample); diff --git a/exercises/E-strings-concatenation/README.md b/.github/exercises/E-strings-concatenation/README.md similarity index 100% rename from exercises/E-strings-concatenation/README.md rename to .github/exercises/E-strings-concatenation/README.md diff --git a/.github/exercises/E-strings-concatenation/exercise.js b/.github/exercises/E-strings-concatenation/exercise.js new file mode 100644 index 000000000..01e6e9d6c --- /dev/null +++ b/.github/exercises/E-strings-concatenation/exercise.js @@ -0,0 +1,7 @@ +// Start by creating a variable `message` +let greeting = "Hello, my name is "; +let name = "Abdirahim"; + +let greetingOutput = greeting + name; + +console.log(greetingOutput); diff --git a/exercises/F-strings-methods/README.md b/.github/exercises/F-strings-methods/README.md similarity index 100% rename from exercises/F-strings-methods/README.md rename to .github/exercises/F-strings-methods/README.md diff --git a/.github/exercises/F-strings-methods/exercise.js b/.github/exercises/F-strings-methods/exercise.js new file mode 100644 index 000000000..35bd0b034 --- /dev/null +++ b/.github/exercises/F-strings-methods/exercise.js @@ -0,0 +1,6 @@ +// Start by creating a variable `message` + +let text = "Abdirahim" +let nameLength = text.length +let message = `My name is ${text} and my name is ${nameLength} characters long` +console.log(message); diff --git a/.github/exercises/F-strings-methods/exercise2.js b/.github/exercises/F-strings-methods/exercise2.js new file mode 100644 index 000000000..5afda2388 --- /dev/null +++ b/.github/exercises/F-strings-methods/exercise2.js @@ -0,0 +1,3 @@ +const text = " Abdirahim "; +const nameLength = text.trim(); +console.log(); \ No newline at end of file diff --git a/exercises/G-numbers/README.md b/.github/exercises/G-numbers/README.md similarity index 100% rename from exercises/G-numbers/README.md rename to .github/exercises/G-numbers/README.md diff --git a/.github/exercises/G-numbers/exercise.js b/.github/exercises/G-numbers/exercise.js new file mode 100644 index 000000000..823f59353 --- /dev/null +++ b/.github/exercises/G-numbers/exercise.js @@ -0,0 +1,7 @@ +// Start by creating a variables `numberOfStudents` and `numberOfMentors` +let numberOfStudents: 15; +let numberOfMentors: 8; +let numberOfStudentsAndMentors: 23; +numberOfStudentsAndMentors = numberOfStudents + numberOfMentors; +let message = `Total number of students and mentors: ${numberOfStudentsAndMentors}`; +console.log(message); \ No newline at end of file diff --git a/exercises/I-floats/README.md b/.github/exercises/I-floats/README.md similarity index 100% rename from exercises/I-floats/README.md rename to .github/exercises/I-floats/README.md diff --git a/.github/exercises/I-floats/exercise.js b/.github/exercises/I-floats/exercise.js new file mode 100644 index 000000000..ee5e879f2 --- /dev/null +++ b/.github/exercises/I-floats/exercise.js @@ -0,0 +1,9 @@ +var numberOfStudents = 15; +var numberOfMentors = 8; + +var numberOfStudentsAndMentors = numberOfStudents + numberOfStudents; +var percentageOfStudents = numberOfStudents / numberOfStudentsAndMentors * 100; +var percentageOfMentors = numberOfMentors / numberOfStudentsAndMentors * 100; + +console.log(`Percentage of students: ${Math.round(percentageOfStudents)}` + "%"); +console.log(`Percentage of mentors: ${Math.round(percentageOfMentors)}` + "%"); \ No newline at end of file diff --git a/exercises/J-functions/README.md b/.github/exercises/J-functions/README.md similarity index 100% rename from exercises/J-functions/README.md rename to .github/exercises/J-functions/README.md diff --git a/exercises/J-functions/exercise.js b/.github/exercises/J-functions/exercise.js similarity index 83% rename from exercises/J-functions/exercise.js rename to .github/exercises/J-functions/exercise.js index 0ae5850e5..0fc4c3655 100644 --- a/exercises/J-functions/exercise.js +++ b/.github/exercises/J-functions/exercise.js @@ -1,5 +1,6 @@ function halve(number) { // complete the function here + return number / 2; } var result = halve(12); diff --git a/exercises/J-functions/exercise2.js b/.github/exercises/J-functions/exercise2.js similarity index 83% rename from exercises/J-functions/exercise2.js rename to .github/exercises/J-functions/exercise2.js index 82ef5e780..468d45596 100644 --- a/exercises/J-functions/exercise2.js +++ b/.github/exercises/J-functions/exercise2.js @@ -1,5 +1,6 @@ function triple(number) { // complete function here + return number * 3; } var result = triple(12); diff --git a/exercises/K-functions-parameters/README.md b/.github/exercises/K-functions-parameters/README.md similarity index 100% rename from exercises/K-functions-parameters/README.md rename to .github/exercises/K-functions-parameters/README.md diff --git a/exercises/K-functions-parameters/exercise.js b/.github/exercises/K-functions-parameters/exercise.js similarity index 84% rename from exercises/K-functions-parameters/exercise.js rename to .github/exercises/K-functions-parameters/exercise.js index 8d5db5e69..dbd50454d 100644 --- a/exercises/K-functions-parameters/exercise.js +++ b/.github/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` diff --git a/exercises/K-functions-parameters/exercise2.js b/.github/exercises/K-functions-parameters/exercise2.js similarity index 65% rename from exercises/K-functions-parameters/exercise2.js rename to .github/exercises/K-functions-parameters/exercise2.js index db7a8904b..b42e1f3fa 100644 --- a/exercises/K-functions-parameters/exercise2.js +++ b/.github/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); console.log(result); diff --git a/.github/exercises/K-functions-parameters/exercise3.js b/.github/exercises/K-functions-parameters/exercise3.js new file mode 100644 index 000000000..f8c180071 --- /dev/null +++ b/.github/exercises/K-functions-parameters/exercise3.js @@ -0,0 +1,8 @@ +// Write your function here +function createGreeting(name){ + return name; +} + +var greeting = createGreeting("Daniel"); + +console.log(`Hello, nice to meet you my name is $(greeting)`); diff --git a/exercises/K-functions-parameters/exercise4.js b/.github/exercises/K-functions-parameters/exercise4.js similarity index 59% rename from exercises/K-functions-parameters/exercise4.js rename to .github/exercises/K-functions-parameters/exercise4.js index 7ab44589e..df2ad1b4f 100644 --- a/exercises/K-functions-parameters/exercise4.js +++ b/.github/exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,7 @@ // Declare your function first - +function total(a, b){ + return a + b; +} // Call the function and assign to a variable `sum` - +const sum = total(102, 79); console.log(sum); diff --git a/.github/exercises/K-functions-parameters/exercise5.js b/.github/exercises/K-functions-parameters/exercise5.js new file mode 100644 index 000000000..3263d1708 --- /dev/null +++ b/.github/exercises/K-functions-parameters/exercise5.js @@ -0,0 +1,6 @@ +// Declare your function here +function createLongGreeting(name,age){ + return `Hello my name is ${name} and I am ${age} years old.`; +} +const greeting = createLongGreeting("Daniel", 30); +console.log(greeting); \ No newline at end of file diff --git a/exercises/L-functions-nested/README.md b/.github/exercises/L-functions-nested/README.md similarity index 100% rename from exercises/L-functions-nested/README.md rename to .github/exercises/L-functions-nested/README.md diff --git a/.github/exercises/L-functions-nested/exercise.js b/.github/exercises/L-functions-nested/exercise.js new file mode 100644 index 000000000..10d573026 --- /dev/null +++ b/.github/exercises/L-functions-nested/exercise.js @@ -0,0 +1,21 @@ +function mentorName(name) { + return name.toUpperCase(); +} +function shoutyGreeting(name) { + var name = mentorName(name); + var message = `HELLO ${name}`; + return message; +} + +var mentor1 = "Daniel"; +var mentor2 = "Irina"; +var mentor3 = "Mimi"; +var mentor4 = "Rob"; +var mentor5 = "Yohannes"; + + +console.log(message(mentor1)); +console.log(message(mentor2)); +console.log(message(mentor3)); +console.log(message(mentor4)); +console.log(message(mentor5)); \ No newline at end of file diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js deleted file mode 100644 index b179ee953..000000000 --- a/exercises/B-hello-world/exercise.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello world"); diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js deleted file mode 100644 index a6bbb9786..000000000 --- a/exercises/C-variables/exercise.js +++ /dev/null @@ -1,3 +0,0 @@ -// Start by creating a variable `greeting` - -console.log(greeting); diff --git a/exercises/D-strings/exercise.js b/exercises/D-strings/exercise.js deleted file mode 100644 index 2cffa6a81..000000000 --- a/exercises/D-strings/exercise.js +++ /dev/null @@ -1,3 +0,0 @@ -// Start by creating a variable `message` - -console.log(message); diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js deleted file mode 100644 index 2cffa6a81..000000000 --- a/exercises/E-strings-concatenation/exercise.js +++ /dev/null @@ -1,3 +0,0 @@ -// Start by creating a variable `message` - -console.log(message); diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js deleted file mode 100644 index 2cffa6a81..000000000 --- a/exercises/F-strings-methods/exercise.js +++ /dev/null @@ -1,3 +0,0 @@ -// Start by creating a variable `message` - -console.log(message); diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js deleted file mode 100644 index b4b46943d..000000000 --- a/exercises/F-strings-methods/exercise2.js +++ /dev/null @@ -1,3 +0,0 @@ -const name = " Daniel "; - -console.log(message); diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js deleted file mode 100644 index 49e7bc00b..000000000 --- a/exercises/G-numbers/exercise.js +++ /dev/null @@ -1 +0,0 @@ -// Start by creating a variables `numberOfStudents` and `numberOfMentors` diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js deleted file mode 100644 index a5bbcd852..000000000 --- a/exercises/I-floats/exercise.js +++ /dev/null @@ -1,2 +0,0 @@ -var numberOfStudents = 15; -var numberOfMentors = 8; diff --git a/exercises/K-functions-parameters/exercise3.js b/exercises/K-functions-parameters/exercise3.js deleted file mode 100644 index 537e9f4ec..000000000 --- a/exercises/K-functions-parameters/exercise3.js +++ /dev/null @@ -1,5 +0,0 @@ -// Write your function here - -var greeting = createGreeting("Daniel"); - -console.log(greeting); diff --git a/exercises/K-functions-parameters/exercise5.js b/exercises/K-functions-parameters/exercise5.js deleted file mode 100644 index 7c5bcd605..000000000 --- a/exercises/K-functions-parameters/exercise5.js +++ /dev/null @@ -1,5 +0,0 @@ -// Declare your function here - -const greeting = createLongGreeting("Daniel", 30); - -console.log(greeting); diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js deleted file mode 100644 index a5d377442..000000000 --- a/exercises/L-functions-nested/exercise.js +++ /dev/null @@ -1,5 +0,0 @@ -var mentor1 = "Daniel"; -var mentor2 = "Irina"; -var mentor3 = "Mimi"; -var mentor4 = "Rob"; -var mentor5 = "Yohannes"; diff --git a/extra/1-currency-conversion.js b/extra/1-currency-conversion.js index 75b3c6aab..f82df6205 100644 --- a/extra/1-currency-conversion.js +++ b/extra/1-currency-conversion.js @@ -5,7 +5,9 @@ Write a function that converts a price to USD (exchange rate is 1.4 $ to £) */ -function convertToUSD() {} +function convertToUSD(inputPrice) { + return inputPrice * 1.4; +} /* CURRENCY CONVERSION @@ -15,7 +17,10 @@ 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(inputPrice) { + let newPrice = inputPrice * (1 - 0.01) * 5.7; + return parseFloat(newPrice.toFixed(2)); +} /* ======= TESTS - DO NOT MODIFY ===== There are some Tests in this file that will help you work out if your code is working. diff --git a/mandatory/1-syntax-errors.js b/mandatory/1-syntax-errors.js index a10cc9ac2..6cc891028 100644 --- a/mandatory/1-syntax-errors.js +++ b/mandatory/1-syntax-errors.js @@ -1,6 +1,6 @@ // 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; } @@ -8,9 +8,9 @@ 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; } /* diff --git a/mandatory/2-logic-error.js b/mandatory/2-logic-error.js index 9cca7603b..f4f2663b6 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; } /* diff --git a/mandatory/3-function-output.js b/mandatory/3-function-output.js index 5a953ba60..30d83702a 100644 --- a/mandatory/3-function-output.js +++ b/mandatory/3-function-output.js @@ -10,9 +10,11 @@ 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. +// Look at the test case below to understand what this function is expected to return. +return firstWord.concat(" ", secondWord, " ", thirdWord); } + /* =================================================== ======= TESTS - DO NOT MODIFY BELOW THIS LINE ===== diff --git a/mandatory/4-tax.js b/mandatory/4-tax.js index ba77c7ae2..45079a04f 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(price) { + return price + price * 0.2; +} /* CURRENCY FORMATTING @@ -17,7 +19,11 @@ function calculateSalesTax() {} Remember that the prices must include the sales tax (hint: you already wrote a function for this!) */ -function addTaxAndFormatCurrency() {} +function addTaxAndFormatCurrency(number) { + var newNumber = calculateSalesTax(number); + newNumber = newNumber.toFixed(2); + return "£" + newNumber; +} /* ===================================================