<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>
<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
Thanks for the link
The first part is correct (calculation of finalResult
)
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.
No I do not know how the code should look like.
I’m happy to do so.
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:
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
When I have some more spare time I’ll look at your other two tasks.
Until then I wish you all the best,
Michael
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.
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.