-
-
Notifications
You must be signed in to change notification settings - Fork 475
NW5-Ahmed_Mahmoud-JavaScript-Core-1-Coursework-Week1 #377
base: master
Are you sure you want to change the base?
Changes from all commits
a71e23b
e00aa8e
ace6306
e812097
9635412
939bed4
4b15858
b2d55d2
89e7dce
a71a19f
1a929e9
a2a2bae
2e974a3
3c73918
fd9f497
0f19df6
016515d
85f27c6
68c4c0b
f356574
347d720
d66fd4c
9758467
dc16d51
032f484
c193fa4
8bdec3c
dfcec4c
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,6 @@ | ||
| console.log("Hello world"); | ||
| console.log("My neme is Ahmed"); | ||
| console.log("I'm Eritrian"); | ||
| console.log("I'm from Manchester"); | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| // Start by creating a variable `greeting` | ||
|
|
||
| let 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,7 @@ | ||
| // Start by creating a variable `message` | ||
|
|
||
| console.log(message); | ||
| var message = "Hello World"; | ||
| 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 = "Hi guys my name is "; | ||
| let fname = "Danti"; | ||
| var message = greetingStart + fname; | ||
|
|
||
| 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); | ||
| let myname = "Danti"; | ||
|
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. camelCase not observed!
Author
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. Yeah that's great idea 👍 |
||
| let message = "My name is" + myname + "and my name is " + myname.length +" characters long"; | ||
| console.log(message); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| const name = " Daniel "; | ||
|
|
||
| const myName = " Daniel "; | ||
| let newName = myName.trim(); | ||
| const message = "My name is" + myName + "and my name is " + newName.length + " characters long"; | ||
|
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 way of using newName.length without declaring any extra variable. |
||
| console.log(message); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| // Start by creating a variables `numberOfStudents` and `numberOfMentors` | ||
| let numberOfStudents = 2; | ||
| let numberOfMentors = 6; | ||
| console.log("Number of mentors: " + numberOfMentors); | ||
| console.log("Number of students: " + numberOfStudents); | ||
| console.log("Total number of students and mentors: " + (numberOfMentors + numberOfStudents)); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| // var numberOfStudents = 15; | ||
| // var numberOfMentors = 8; | ||
| var preciseAge = 30.612437; | ||
| var result = preciseAge / 10; | ||
| var resultWhole = Math.round(result); | ||
| console.log(resultWhole + ": " + "%"); |
| 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,9 +1,10 @@ | ||
| // 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` | ||
| var result = multiply(3, 4); | ||
|
|
||
| multiply() | ||
|
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. Calling function before console.log is useless, you can remove it and test it again and still get the results. |
||
| console.log(result); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| // Declare your function first | ||
|
|
||
| function divide(a , b) { | ||
|
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. Observe your spaces between parameters (a, b) in order to keep your parameters neat. |
||
| return a / b; | ||
| } | ||
|
|
||
| var result = divide(3, 4); | ||
|
|
||
| console.log(result); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| // Write your function here | ||
| function createGreeting(myName) { | ||
| return "Hello, my name is " + myName; | ||
| } | ||
|
|
||
| var greeting = createGreeting("Daniel"); | ||
| var greeting = createGreeting("Danti"); | ||
|
|
||
| console.log(greeting); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| // Declare your function first | ||
|
|
||
| function sum (a,b) { | ||
| return sum = a + b; | ||
| } | ||
| // Call the function and assign to a variable `sum` | ||
|
|
||
| sum(13,124) | ||
| console.log(sum); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| // Declare your function here | ||
| function createLongGreeting(a,b) { | ||
| return "Hello My name is " + a + "and I'm " + b + "years old"; | ||
| } | ||
|
|
||
| const greeting = createLongGreeting("Daniel", 30); | ||
|
|
||
|
|
||
| const greeting = createLongGreeting("Danti ", 30); | ||
|
|
||
| console.log(greeting); | ||
|
|
||
|
|
||
|
|
||
|
|
||
| // - Write a function that takes a name (a string) and an age (a number) and returns a greeting (a string) | ||
|
|
||
| // ## Expected result | ||
|
|
||
| // ``` | ||
| // Hello, my name is Daniel and I'm 30 years old | ||
| // ``` |
| 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 danti(a) { | ||
| return "HELOW"; | ||
|
|
||
| } | ||
| console.log(danti() + " " + mentor1.toUpperCase() ); | ||
| console.log(danti() + " " + mentor2.toUpperCase() ); | ||
| console.log(danti() + " " + mentor3.toUpperCase() ); | ||
| console.log(danti() + " " + mentor4.toUpperCase() ); | ||
| console.log(danti() + " " + mentor5.toUpperCase() ); | ||
|
Comment on lines
+7
to
+16
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 solution does not work, and you receive an error message!
|
||
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.
I see everything is fine, but remember to use camelCase when naming your variables.
let fname > let firstName or fName