I am trying to achieve a check with the if...else statement that only squares the odd numbers between 100 and 150, otherwise the number is just printed.
How can I revise my if statement to achieve this please? An educated guess is that an operator or combination of operators are used.
for (i=100; i<=150; i++)
{
if (i === 0)
{
console.log(i * i);
}
else
{
console.log(i);
}
}
The operator you are looking for is
%:a % bis basically the remainder obtained whenais divided byb. It’s called the modulus operator.