-
-
Notifications
You must be signed in to change notification settings - Fork 476
Manchester-NW5-Esam-Ahmed- Javascript-week2 #409
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello World. I just started learning JavaScript!"); | ||
| console.log("hi there!") | ||
| console.log(44); | ||
|
|
||
| var greeting = "Hello world"; | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `message` | ||
| var letter ="from home office"; | ||
| var letterType = typeof letter; | ||
| console.log(letterType); | ||
|
|
||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `message` | ||
| var greetingWord = "Hi, my name is "; | ||
| var names = "Esam!"; | ||
|
|
||
| var message = greetingWord + names; | ||
| console.log(message); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| console.log(message); | ||
| var names = " Esam "; | ||
| var nameLength = names.trim(); | ||
| console.log(nameLength); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of .trim. You also need to use .length to get the number of letters in the name. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| const name = " Daniel "; | ||
| const names = " Daniel "; | ||
| const message = names.trim(); | ||
| // const nameLength = names.length; | ||
|
|
||
| console.log(message); | ||
| console.log(nameLength); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with the previous exercise, you need to use .length to get the number of letters in the name |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| var numberOfStudents = 45; | ||
| var numberOfMentors = 10; | ||
| var TotalOfAll = numberOfMentors + numberOfStudents; | ||
| console.log(TotalOfAll); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your code is correctly adding 2 numbers and outputting the result. If you read the question and expected output, you will see that you should be using different numbers and outputting more details. Also, variable names in Javascript are normally in lower camel case, i.e. totalOfAll |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| var total = numberOfMentors + numberOfStudents; | ||
|
|
||
| var studentPercent = "Percentage Students:" + Math.round((numberOfStudents / total) * 100 ) + "%"; | ||
| var mentorPercent = "Percentage Mentors:" + Math.round((numberOfMentors / total) * 100) + "%"; | ||
| console.log(studentPercent); | ||
| console.log(mentorPercent); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of Math library |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| function triple(number) { | ||
| // complete function here | ||
| return number * 3; | ||
| } | ||
|
|
||
| var result = triple(12); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // Declare your function first | ||
|
|
||
| function divide(num1, num2) { | ||
| return num1 / num2; | ||
| } | ||
| var result = divide(3, 4); | ||
|
|
||
| console.log(result); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| // Write your function here | ||
|
|
||
| function createGreeting(name){ | ||
| return "Hello, my name is " + name; | ||
| } | ||
| var greeting = createGreeting("Daniel"); | ||
|
|
||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Declare your function first | ||
|
|
||
| function addition(num1,num2){ | ||
| return num1 + num2; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
| var sum = addition(13, 124); | ||
|
|
||
| console.log(sum); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| // Declare your function here | ||
|
|
||
| function createLongGreeting (name, age){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of meaningful variable names |
||
| return "Hello, my name is " + name + " and I'm " + age +" years old"; | ||
| } | ||
| const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
| console.log(greeting); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,24 @@ | ||
|
|
||
| var mentor1 = "Daniel"; | ||
| var mentor2 = "Irina"; | ||
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
|
|
||
| function uppercaseName(name){ | ||
| var updatedName = name.toUpperCase(); | ||
| return updatedName; | ||
| } | ||
|
|
||
| function shouti(mentor){ | ||
| var mentorName = uppercaseName(mentor); | ||
| var message = "Hello " + mentorName; | ||
| console.log(message); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have clearly understood how to call one function from another, and again, you have used goo variable names. |
||
| shouti(mentor1); | ||
| shouti(mentor2); | ||
| shouti(mentor3); | ||
| shouti(mentor4); | ||
| shouti(mentor5); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of a variable.