"Assessment wanted for Math 2 skill test"

Hello! I am doing it now - https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Test_your_skills:_Math#Math_2

Stuck in paragraph 4 - “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.”

I don’t understand how to do this and thanks for the help.

My decision is the first three points.

 <script>
  // Final result should be 10.42
  // Add/update your code here

let result = 7 + 13 / 9 + 7;
let result2 = 100 / 2 * 6;
result *= result2;
let finalResult = result.toFixed(2);
let  finalNumber = Number(finalResult);
  

    // Don't edit the code below here!

    const section = document.querySelector('section');

    let para1 = document.createElement('p');
    para1.textContent = `Your finalResult is ${ finalResult }`;
    let para2 = document.createElement('p');
    let finalNumberCheck = typeof finalNumber === 'number' ? 'finalNumber is a number type. Well done!' : `Ooops! finalNumber is of type ${ typeof finalNumber }.`
    para2.textContent = finalNumberCheck;

    section.appendChild(para1);
    section.appendChild(para2);
  </script>

https://codepen.io/maksim-honchar/pen/xxbepBe

Hi @Maksym.Honchar!

Let me give you a clue. To fix the equations you need to override operator precedence. What symbols can you add to do that?

2 Likes

Hello! Thank you!)

let result = (7 + 13) / (9 + 7);
let result2 = 100 / (2 * 6);

perfect, well done! This is exactly what I was looking for :wink:

1 Like