NW5-Ahmed_Mahmoud-JavaScript-Core-1-Coursework-Week1 - #377
Conversation
| @@ -1,3 +1,6 @@ | |||
| // Start by creating a variable `message` | |||
| var greetingStart = "Hi guys my name is "; | |||
| let fname = "Danti"; | |||
There was a problem hiding this comment.
I see everything is fine, but remember to use camelCase when naming your variables.
let fname > let firstName or fName
| // Start by creating a variable `message` | ||
|
|
||
| console.log(message); | ||
| let myname = "Danti"; |
|
|
||
| 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.
Nice way of using newName.length without declaring any extra variable.
| // var numberOfStudents = 15; | ||
| // var numberOfMentors = 8; | ||
| var preciseAge = 30.612437; | ||
| var result = preciseAge / 10; | ||
| var resultWhole = Math.round(result); | ||
| console.log(resultWhole + "%"); No newline at end of file |
There was a problem hiding this comment.
Please have look again at the Readme file because the instruction expects something else.
Please let me know if you find any straggling!
Exercise
- Using the variables provided in the exercise calculate the percentage of mentors and students in the group
Expected result
Percentage students: 65%
Percentage mentors: 35%
| // Assign the result of calling the function the variable `result` | ||
| var result = multiply(3, 4); | ||
|
|
||
| multiply() |
There was a problem hiding this comment.
Calling function before console.log is useless, you can remove it and test it again and still get the results.
| @@ -1,5 +1,9 @@ | |||
| // Declare your function first | |||
|
|
|||
| function divide(a , b) { | |||
There was a problem hiding this comment.
Observe your spaces between parameters (a, b) in order to keep your parameters neat.
|
|
||
| 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() ); No newline at end of file |
There was a problem hiding this comment.
The solution does not work, and you receive an error message!
Here are some threads to fix the error:
- For all of our mentors' names to be in uppercase, you need to declare that in your function, for example: return "Hello" + n.toUpperCase();
- You can call your function from the console.log and pass the mentors' variables as parameters.
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
How to create a new var, let and const.
How to use return'
How to use more than function in one function.