Math, asked by Rakshita4486, 11 months ago

Write a script that reads an integer and determines and output html5 text that displays whether it is odd or even

Answers

Answered by Anonymous
12

The shortest way to write it would be:

document.write("<h2> is an "+(num % 2 ? "odd" : "even")+" number</h2>");

[EDIT] The original solution does not work because only a single "=" is used to test equality. In Javascript, you must use either "==" (loose equality) or "===" strict equality.

Hope this helps ☺️☺️☺️

Similar questions