London class 9 - Natalie Zablotska - JavaScript - Core - 1 - Week1#444
London class 9 - Natalie Zablotska - JavaScript - Core - 1 - Week1#444nataliiazab wants to merge 11 commits into
Conversation
|
@Hamisakim please review the js tasks once you have time. thanks!! |
| var greeting = 'Hi, my name is '; | ||
| var myName = 'Natalie.'; | ||
|
|
||
| message = greeting + myName; |
There was a problem hiding this comment.
we need to define message with const message = greeting + myName;
|
|
||
| let myName = name.trim(); | ||
| let nameLength = myName.length; | ||
| message = |
Hamisakim
left a comment
There was a problem hiding this comment.
Hey Natalie. Not your fault since the examples used this, but going forwards always use let or const when defining variables. var is not used anymore :)
In some places you were able to define a variable like message = a + b this is because your IDE is not using javascript in strict mode. I'll talk about this in class more, but have a read online about this
Another way, which i prefer, to concate strings is a string literal have a look below.
Both messages will output the same
const name = 'John Doe'
const age = '30'
const job = 'Web Developer'
const message = `My name is ${name} and I am ${age} years old. I am a ${job}`
const message1 = 'My name is ' + name + ' and I am ' + age + ' years old. I am a ' + job
// My name is John Doe and I am 30 years old. I am a Web Developer
If you need more clarity let me know
| var numberOfStudents = 15; | ||
| var numberOfMentors = 8; | ||
| let total = numberOfMentors + numberOfStudents; | ||
| console.log('Total number of students and mentors:' + ' ' + total); No newline at end of file |
There was a problem hiding this comment.
You can add a space at the end of the string here rather than having + ' '
console.log('Total number of students and mentors: ' + total);
| total = a ++ b; | ||
|
|
||
| return "The total is total"; | ||
| total = a + b; |
|
thanks very much for the comments, @Hamisakim . This is noted |
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
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?