2/14 question. beginner question



Have a beginner question. Can't believe I have it so far into the lesson, but I was curious why in the section for

if(number % 2 ===0)

Why do we put the "===0" before the divisible, but we didn't in lesson 1/14??

var isEven = function(number) {

if (number % 2 === 0) {
return true;
else if (isNaN(number)){
return ("The number you wrote isn't a number");
else {
return false;



Javascript has the so-called modulo / remainder-operator if used it will return the rest-value.

9%3 You read it as nine modulo three is zero, as 9 divided by 3 has NO rest-value.
22%6 You read 22 modulo six is 4, as 22 divided by 6 will leave you with rest-value 4
16%8 You read it as sixteen modulo eight is zero, as sixteen divided by 8 has NO rest-value

google search
== the Book ==
javascript remainder operator site:developer.mozilla.org
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators

== discussions / opinions ==
javascript remainder operator site:stackoverflow.com
= http://stackoverflow.com/questions/4467539/javascript-modulo-not-behaving
javascript array site:developer.mozilla.org
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

== guidance ==
= http://javascript.crockford.com/survey.html
= http://javascript.crockford.com/code.html


I keep on submitting my answer but it says " oops the ul element should have 3 li elements."


Is your problem in anyway related to the javaScript course "9. More on Control Flow"? If not you're probably better of finding the correct category and posting your question with your code and the error message there. Also in any case posting your question in an own thread is better than hijacking another thread. thank you.


Just curious is the input isEven(10); at the bottom of your code a significant piece to the code? @seth_white23. I am a beginner and im trying to get as detailed as possible on all my code :smile:
I was able to pass the lesson with this code

var isEven = function(number) {
if(number % 2 === 0) {
return true
} else if (isNaN (number)) {
return ("The number isn't a number!");
else {
return false;


No it's not required for the exercise but it is a test if it is working. You call the function with an even number in if it works correctly you should get the result true.



Just curious is the input isEven(10);

With isEven(10); you are calling the =isEven= function.

The isEven function was defined as having 1 parameter number
and as you call the function
and the isEven function was defined as having 1 parameter
you will have to provide 1 argument
in this case it could either be a string Value or a number Value

But as you are using the return statement
the function will return a result with NOdisplay.

You can capture the result with
var theResult = isEven(10);
and then do a display with
console.log( theResult );
directly with
console.log( isEven(10) );


function with 1 parameter using return-statement

var myFunction = function( param1 ) {
       //Begin of FUNCTION-BODY
       //myFunction =function= has 1 PARAMETER param1
       //this param1 PARAMETER is used as a -local- VARIABLE
       //throughout the FUNCTION-BODY

      return param1;

      //End of FUNCTION-BODY

you have defined a myFunction function
which takes 1 parameter param1
this param1 parameter is used
as a variable throughout the FUNCTION-BODY.

If you want to call/execute this myFunction function
and this myFunction function was defined
as having 1 parameter param1
you will have to provide 1 argument
in our case a "number VALUE" 4
myFunction( 4 );

some quotes from the outer-world:

**argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block**


**"parameters" are called "formal parameters",
while "arguments" are called "actual parameters".**



In your isEven function i would
check if the given argument
has a string Value
BEFORE you use the remainder operator on a number Value


Thank you so much for the detailed answer! I really appreciate and I am understanding the concept now :smile: