diff --git a/exercises/B-hello-world/README.md b/exercises/B-hello-world/README.md index 8c704fb43..d3fefa036 100644 --- a/exercises/B-hello-world/README.md +++ b/exercises/B-hello-world/README.md @@ -14,5 +14,5 @@ Inside of `exercise.js` there's a line of code that will print "Hello world!". - Try to `console.log()` something different. For example, 'Hello World. I just started learning JavaScript!'. - Try to console.log() several things at once. -- What happens when you get rid of the quote marks? +- What happens when you get rid of the quotation mark? - What happens when you console.log() just a number without quotes? diff --git a/exercises/B-hello-world/exercise.js b/exercises/B-hello-world/exercise.js index b179ee953..00b135b46 100644 --- a/exercises/B-hello-world/exercise.js +++ b/exercises/B-hello-world/exercise.js @@ -1 +1,4 @@ -console.log("Hello world"); +console.log("Hello world, I just started to learning JavaScript!"); +console.log("Good Morning!"); +console.log(15); +//console.log(without quotation mark); diff --git a/exercises/C-variables/exercise.js b/exercises/C-variables/exercise.js index a6bbb9786..9a882f99f 100644 --- a/exercises/C-variables/exercise.js +++ b/exercises/C-variables/exercise.js @@ -1,3 +1,5 @@ // 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..1f2614746 100644 --- a/exercises/D-strings/exercise.js +++ b/exercises/D-strings/exercise.js @@ -1,3 +1,7 @@ // Start by creating a variable `message` +var message = "This is a string"; +var messageType = typeof message; + console.log(message); +console.log(messageType); \ No newline at end of file diff --git a/exercises/E-strings-concatenation/exercise.js b/exercises/E-strings-concatenation/exercise.js index 2cffa6a81..85c32c15d 100644 --- a/exercises/E-strings-concatenation/exercise.js +++ b/exercises/E-strings-concatenation/exercise.js @@ -1,3 +1,7 @@ // Start by creating a variable `message` +var greetingStart = "Hello, my name is "; +var fname = "Mya"; -console.log(message); +var greeting = greetingStart + fname; + +console.log(greeting); diff --git a/exercises/F-strings-methods/exercise.js b/exercises/F-strings-methods/exercise.js index 2cffa6a81..961c9aa10 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` +var myName = "Mya"; +var myNameLength = myName.length; +var message = `My name is ${myName} and my name got ${myNameLength} characters long`; console.log(message); diff --git a/exercises/F-strings-methods/exercise2.js b/exercises/F-strings-methods/exercise2.js index b4b46943d..ceffca781 100644 --- a/exercises/F-strings-methods/exercise2.js +++ b/exercises/F-strings-methods/exercise2.js @@ -1,3 +1,6 @@ -const name = " Daniel "; +const myName = " Daniel "; +var myNameTrim = myName.trim(); +var myNameLength = myName.length; +var message = `My name is ${myNameTrim} and my name got ${myNameLength} characters long`; console.log(message); diff --git a/exercises/G-numbers/README.md b/exercises/G-numbers/README.md index 76a79dab2..75136adf1 100644 --- a/exercises/G-numbers/README.md +++ b/exercises/G-numbers/README.md @@ -6,7 +6,7 @@ Unlike strings, numbers do not need to be wrapped in quotes. var age = 30; ``` -You can use mathematical operators to caclulate numbers: +You can use mathematical operators to calculate numbers: ```js var sum = 10 + 2; // 12 @@ -25,5 +25,5 @@ var difference = 10 - 2; // 8 ``` Number of students: 15 Number of mentors: 8 -Total numnber of students and mentors: 23 +Total number of students and mentors: 23 ``` diff --git a/exercises/G-numbers/exercise.js b/exercises/G-numbers/exercise.js index 49e7bc00b..0d7487761 100644 --- a/exercises/G-numbers/exercise.js +++ b/exercises/G-numbers/exercise.js @@ -1 +1,11 @@ // Start by creating a variables `numberOfStudents` and `numberOfMentors` +let numberOfStudents = 15; +let numberOfMentors = 8; +let totalNumber = numberOfStudents + numberOfMentors; + +console.log(`Number of students: ${numberOfStudents}`); +console.log(`Number of mentors: ${numberOfMentors}`); +console.log(`Total number of students and mentors: ${totalNumber}`); +// Number of students: 15 +// Number of mentors: 8 +// Total number of students and mentors: 23 diff --git a/exercises/I-floats/exercise.js b/exercises/I-floats/exercise.js index a5bbcd852..87d493469 100644 --- a/exercises/I-floats/exercise.js +++ b/exercises/I-floats/exercise.js @@ -1,2 +1,13 @@ var numberOfStudents = 15; var numberOfMentors = 8; + +let percentageOfStudents = (15 / 23) * 100; +let percentageOfMentors = (8 / 23) * 100; + +let studentsRounded = Math.round(percentageOfStudents); +let mentorsRounded = Math.round(percentageOfMentors); +console.log(`Percentage of students: ${studentsRounded} % `); +console.log(`Percentage of mentors: ${mentorsRounded} %`); +// Number of students: 15 +// Number of mentors: 8 +// Total number of students and mentors: 23 diff --git a/exercises/J-functions/exercise.js b/exercises/J-functions/exercise.js index 0ae5850e5..8d819a4f7 100644 --- a/exercises/J-functions/exercise.js +++ b/exercises/J-functions/exercise.js @@ -1,7 +1,13 @@ function halve(number) { // complete the function here + return number / 2 } -var result = halve(12); - -console.log(result); +var result1 = halve(12); +var result2 = halve(50); +var result3 = halve(350); +var result4 = halve(2540); +console.log(result1); +console.log(result2); +console.log(result3); +console.log(result4); diff --git a/exercises/J-functions/exercise2.js b/exercises/J-functions/exercise2.js index 82ef5e780..e395b89b2 100644 --- a/exercises/J-functions/exercise2.js +++ b/exercises/J-functions/exercise2.js @@ -1,7 +1,13 @@ function triple(number) { // complete function here + return number * 3; } var result = triple(12); - +var result1 = triple(9); +var result2 = triple(300); +var result3 = triple(78920); console.log(result); +console.log(result1); +console.log(result2); +console.log(result3); diff --git a/exercises/K-functions-parameters/exercise.js b/exercises/K-functions-parameters/exercise.js index 8d5db5e69..a4eed9d76 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(num1, num2) { // Calculate the result of the function and return it + return num1 * num2; } // Assign the result of calling the function the variable `result` diff --git a/exercises/K-functions-parameters/exercise2.js b/exercises/K-functions-parameters/exercise2.js index db7a8904b..a600cab48 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 (num1, num2) { + return num1 / num2; +} var result = divide(3, 4); console.log(result); diff --git a/exercises/K-functions-parameters/exercise3.js b/exercises/K-functions-parameters/exercise3.js index 537e9f4ec..bdfe05005 100644 --- a/exercises/K-functions-parameters/exercise3.js +++ b/exercises/K-functions-parameters/exercise3.js @@ -1,5 +1,7 @@ // Write your function here - +function createGreeting(name) { + return "Hello, my name is " + name; +} var greeting = createGreeting("Daniel"); console.log(greeting); diff --git a/exercises/K-functions-parameters/exercise4.js b/exercises/K-functions-parameters/exercise4.js index 7ab44589e..c6f35cada 100644 --- a/exercises/K-functions-parameters/exercise4.js +++ b/exercises/K-functions-parameters/exercise4.js @@ -1,5 +1,8 @@ // Declare your function first - +function addsNumber(num1, num2) { + return num1 + num2; +} // Call the function and assign to a variable `sum` +var sum = addsNumber(13,124); console.log(sum); diff --git a/exercises/K-functions-parameters/exercise5.js b/exercises/K-functions-parameters/exercise5.js index 7c5bcd605..1d37ea143 100644 --- a/exercises/K-functions-parameters/exercise5.js +++ b/exercises/K-functions-parameters/exercise5.js @@ -1,5 +1,7 @@ // Declare your function here - -const greeting = createLongGreeting("Daniel", 30); +function createGreeting(name, age) { + return "Hello, my name is " + name + " and I'm " + age + " years old"; +} +const greeting = createGreeting("Daniel", 30); console.log(greeting); diff --git a/exercises/L-functions-nested/README.md b/exercises/L-functions-nested/README.md index 1c4ae9c8a..012be64e0 100644 --- a/exercises/L-functions-nested/README.md +++ b/exercises/L-functions-nested/README.md @@ -9,7 +9,7 @@ function getAgeInDays(age) { return age * 365; } -function createCreeting(name, age) { +function createGreeting(name, age) { var ageInDays = getAgeInDays(age); var message = "My Name is " + name + " and I was born over " + ageInDays + " days ago!"; diff --git a/exercises/L-functions-nested/exercise.js b/exercises/L-functions-nested/exercise.js index a5d377442..550119217 100644 --- a/exercises/L-functions-nested/exercise.js +++ b/exercises/L-functions-nested/exercise.js @@ -3,3 +3,20 @@ var mentor2 = "Irina"; var mentor3 = "Mimi"; var mentor4 = "Rob"; var mentor5 = "Yohannes"; + +function createGreeting(mentor) { + return "hello " + mentor; +} + +function greetingInUpperCase(mentor) { + var greeting = createGreeting(mentor); + return (greeting = greeting.toLocaleUpperCase()); +} + +//var greeting = createGreeting(mentor1); + +console.log(greetingInUpperCase(mentor1)); +console.log(greetingInUpperCase(mentor2)); +console.log(greetingInUpperCase(mentor3)); +console.log(greetingInUpperCase(mentor4)); +console.log(greetingInUpperCase(mentor5));