-
-
Notifications
You must be signed in to change notification settings - Fork 475
JavaScript-Core1-Week1-Niamh Madden #131
Changes from all commits
721242d
d2c5d28
76aeaff
fd8a9d3
04a90f2
b1e8571
f5e15cb
f9b2271
1b649d6
b1abfc8
f0c6370
02a2787
8bcd641
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,4 @@ | ||
| console.log("Hello world"); | ||
| console.log("Hello Guys, I am learning JavaScript") | ||
| console.log (Hello) | ||
| console.log(1000) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| var greeting = "Hello Everyone" | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| var message = "Hello" | ||
| var messageType = typeof message; | ||
| console.log(message); | ||
| console.log(messageType); | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Start by creating a variable `message` | ||
| var greetingStart = "Hello, my name is " | ||
| var name = "Niamh" | ||
|
|
||
| console.log(message); | ||
| var greeting = greetingStart + name; | ||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| // Start by creating a variable `message` | ||
| var name = "Niamh"; | ||
|
|
||
| var nameLength = name.length; | ||
|
|
||
| console.log(nameLength) | ||
|
|
||
| console.log(message); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| var numberOfStudents = 50; | ||
| var numberOfMentors = 10; | ||
|
|
||
| var sum = numberOfStudents + numberOfMentors; | ||
|
|
||
| console.log(sum); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
|
|
||
| var percentageOfStudents = 15 /23 * 100; | ||
| var percentageOfMentors = 8/23*100; | ||
|
|
||
|
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. nice, you could use the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| function halve(number) { | ||
| // complete the function here | ||
| return number / 2; | ||
| } | ||
|
|
||
| var result = halve(12); | ||
| var result = halve(10000100101010); | ||
|
|
||
| console.log(result); |
| 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,7 @@ | ||
| // 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 | ||
|
|
||
| fucntion greeting(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,10 @@ | ||
| // Declare your function first | ||
| function add(num1, num2) { | ||
| return num1 + num2; | ||
| } | ||
|
|
||
| // Call the function and assign to a variable `sum` | ||
| const sum = add(13, 200) | ||
|
|
||
|
|
||
| console.log(sum); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| // Declare your function here | ||
|
|
||
| function createGreeting(name, age){ | ||
| return `Hello, my name is ${name} and I am ${age} years old.`; | ||
| } | ||
|
|
||
| const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,14 @@ var mentor2 = "Irina"; | |
| var mentor3 = "Mimi"; | ||
| var mentor4 = "Rob"; | ||
| var mentor5 = "Yohannes"; | ||
|
|
||
| function shoutGreeting (name){ | ||
| name = name.toUpperCase(); | ||
| console.log(`Hello ${name}`); | ||
| } | ||
|
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. the idea of this exercise was to have 2 separate functions, one that returns the name in uppercase and another that returns the greeting by calling the first function to get the name |
||
|
|
||
| shoutGreeting(mentor1); | ||
| shoutGreeting(mentor2); | ||
| shoutGreeting(mentor3); | ||
| shoutGreeting(mentor4); | ||
| shoutGreeting(mentor5); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| // 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"; | ||
|
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. there is still a syntax error on this line |
||
|
|
||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| total = a + b; | ||
|
|
||
| return "The total is total"; | ||
| return `The total is $total`; | ||
|
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 are missing {} around total |
||
| } | ||
|
|
||
| /* | ||
|
|
||
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.
well done on getting the length of the name, you missed part of the exercise where you concatenate the string and use the
trim()method 🙂