Can I get an Evaluation for Math Exercise 1

<meta charset="utf-8" />

<title>Math: Task 1</title>

<style>

    p {

        color: purple;

        margin: 0.5em 0;

    }

   

    * {

        box-sizing: border-box;

    }

</style>
<section class="preview">

</section>

Here is the link for the Test 1

Math 1

Thanks for the link :slightly_smiling_face:

The first part is correct (calculation of finalResult) :white_check_mark:
The second part (evenOddResult) doesn’t check if finalResult is even or odd. evenOddResult should contain 0 if finalResult is even and 1 if finalResult is odd. The operator you need here is the remainder operator (%). Do you know how the code should look like?

Happy coding,
Michael

Thank you for confirming that resubmission worked.

There were no errors so I assumed everything was correct.

I see what you mean and I need help with how the code would look like.

Thanks for your help.

Sincerely,
Budoa.

1 Like

No I do not know how the code should look like.

I’m happy to do so. :blush:
There is no need for the if statement. You can write:

evenOddResult = finalResult % 2;

Why does that work? When we use % JavaScript divides the two numbers, but instead of returning the result of the division it returns the (whole number) remainder. For example:

  • 48 % 2 = 0 :arrow_right: 2 fits into 48 24 times and there is nothing left
  • 49 % 2 = 1 :arrow_right: 2 fits into 49 24 times and there is 1 left
  • 11 % 4 = 3 :arrow_right: 4 fits into 11 2 times and there are 3 left

When we do finalResult % 2 we get 0 if finalResult is even (nothing left) and we get 1 if finalResult is odd (1 is left).

I hope I could explain it good enough. If you need more help to understand it feel free to ask questions :slightly_smiling_face:
When I have some more spare time I’ll look at your other two tasks.

Until then I wish you all the best,
Michael

1 Like

Thank you sir for the clarification.

I look forward to hearing from about the other two exercises…

I have been going through YouTube about JS/HTML/CSS classes and felt that, since I am using MDN quite often for references and than found these classes, I decided to stick with MDN.

Thanks again and look forward to learning more.

1 Like

I’m glad you find the content on MDN helpful. Working through the MDN learning area is a great way to gain a general understanding of the different web technologies.

I’ll now look at your other two exercises. Expect my answers soon. :grinning: