This isn’t quite right. Let me walk you through the steps:
- Write a calculation that multiplies
result
and result2
together and assigns the result back to result
. This will require assignment shorthand.
I’m not sure why you used the if
statement here. It always run because what’s inside the parenthesis is always true
. We just need to multiply the two numbers and assign them. This would be the correct assignment: result *= result2;
It is the short version of result = result * result2;
which would also work.
- Write a line of code that takes result and formats it to 2 decimal places, storing the result of this in a variable called
finalResult
.
To format the number we need the toFixed()
method.
- Check the data type of
finalResult
using typeof
; you’ll probably see that it is actually of string
type! Write a line of code that converts it to a number
type, storing the result in a variable called finalNumber
.
Since the toFixed()
method returns a string we need the Number()
constructor to convert the string to a number.
- The value of
finalNumber
needs to be 10.42
. Go back and update the original calculations you were provided with so that they give this final result. Don’t update the numbers or the operators.
To achieve this we need to add three pairs of parentheses to our initial calculations. This should look something like this:
let result = (...) / (...);
let result2 = 100 / (...);
You don’t need to change the numbers or operators. Just add the parentheses.
I hope this gives you enough hints to improve your code. It’s a pretty tricky one, so don’t get discouraged. You can do it.