London 9 olus odude js1 wk1 - #413
Conversation
maxf
left a comment
There was a problem hiding this comment.
Very good start with JS. A few minor comments.
| @@ -1,3 +1,5 @@ | |||
| // Start by creating a variable `greeting` | |||
|
|
|||
| let greeting = "Hello World"; | |||
There was a problem hiding this comment.
Small detail: the variable's value doesn't change, so you might as well use const, just so it becomes a habit.
| let bRail = pound * 5.7; | ||
| console.log(bRail); | ||
| let railAndFee = bRail * 0.99; | ||
| console.log(railAndFee); |
There was a problem hiding this comment.
Hint: when you have multiple console.log in your code it can become confusing which one is printing which value. So you can use instead:
console.log("value of bRail", bRail);
or
console.log('Here>', railAndFee)
This works because console.log() takes any number of arguments and prints all of them. For instance,
console.log('Hello', 'World', 3.14)
| return "Hello, my name is " + name "and I am " age + "years old"; | ||
| function introduceMe(name, age) { | ||
| return "Hello, my name is " + `${name}` + " and I am " + `${age}` + " years old"; | ||
| } |
There was a problem hiding this comment.
This works, but is a bit convoluted :)
I think the idea was to add the missing + and whitespace characters
|
|
||
| function getTotal(a, b) { | ||
| total = a ++ b; | ||
| total = a + b; |
There was a problem hiding this comment.
use const. Even if the variable is declared without const or let, it's a bad idea not to use either.
| expect(introduceMe("Sonjide", 27)).toEqual( | ||
| "Hello, my name is Sonjide and I am 27 years old" | ||
| ); | ||
| expect(introduceMe("Sonjide", 27)).toEqual("Hello, my name is Sonjide and I am 27 years old"); |
| expect(trimWord(" CodeYourFuture teaches coding ")).toEqual( | ||
| "CodeYourFuture teaches coding" | ||
| ); | ||
| expect(trimWord(" CodeYourFuture teaches coding ")).toEqual("CodeYourFuture teaches coding"); |
| //the number is never equal to 1. times the nubmeer by 10 | ||
| //creates a random numbere between 0 and <10. | ||
| /* | ||
| google say : The Math.random() function returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1, with approximately uniform distribution over that range — which you can then scale to your desired range |
There was a problem hiding this comment.
Not google :) Mozilla Developer Network - the best reference
| /* | ||
| // function does decimaal conversion and tax | ||
| function calculateSalesTax(price) { | ||
| //convert number to decimall place twin | ||
| let newPrice = price.toFixed(2); | ||
| //convert numb form string back to numb | ||
| let usePrice = newPrice * 1; | ||
| console.log(typeof usePrice); | ||
| console.log(usePrice); | ||
| let taxPrice = usePrice * 1.2; | ||
| let showPrice = taxPrice.toFixed(2); | ||
| console.log(showPrice); | ||
| return `£ ${showPrice}`; | ||
| } | ||
| calculateSalesTax(15); | ||
| */ |
added a message variable
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?
function were ok,
What did you find hard?
trying to find the best method for decimalising a price
an efficient setup for running test with node
What do you still not understand?
if jest needs to be installed in every new project or if their is a way to reference it from a separate repository
when is best to commit when working on functions
Any other notes?
only mandatory folder has been completed, the rest will follow