WM4 - Robert_Csonka - JavaScript_core1 - week_1 - #340
Conversation
| let number | ||
| console.log('number') | ||
| console.log(3434) | ||
| console.log("The third line will be an error") |
There was a problem hiding this comment.
Just a minor correction: The third line would be undefined but not an error. It is a valid JavaScript to declare a variable and later assign a value to it like:
let number;
number = 33;
Also if you were trying to console log the third line in line number 4, you don't need to wrap it in a quotation as it is a variable. You can simply do console.log(number) which will print undefined in the console but console.log('number') gives you number as a string value.
| var greeting = "Hello World!" | ||
| console.log(greeting); | ||
| console.log(greeting); | ||
| console.log(greeting); |
There was a problem hiding this comment.
The above lines work well.
You could also combine multiple console logs like this:
console.log(greeting, greeting, greeting)
| var message | ||
| var name = "Robert" | ||
| var nameLength = name.length | ||
| message = "My name is " + name + " and my name is " + nameLength + " characters long" |
There was a problem hiding this comment.
Nice and neat string concatenation!
| function convertToUSD(poundToUsd) { | ||
| return poundToUsd * 1.4; | ||
| } | ||
|
|
There was a problem hiding this comment.
Well done on solving an extra assignment!!
The parameter poundToUsd sounds as if it's a function.
For further improvement, you may want to change it into pound, amountInPound, or something more semantic.
|
|
||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| total = a + b; |
There was a problem hiding this comment.
The variable total hasn't been declared and it will give you a reference error.
You need something like:
let total = a + b;
| function multiply(a, b, c) { | ||
| return a * b * c; | ||
| } | ||
|
|
There was a problem hiding this comment.
You've spotted all the errors!
Great job!
| return firstWord.concat(" ", secondWord, " ", thirdWord); | ||
| } | ||
|
|
||
| /* |
There was a problem hiding this comment.
Well done!
Great comments and sound solutions!
| function addTaxAndFormatCurrency(price) { | ||
|
|
||
| return "£" + calculateSalesTax(price).toFixed(2); | ||
| } |
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?
View rendered exercises/C-variables/README.md