If / else



No error message. Question - How does the computer know that the variable "number" is an actual number? Is this an assumption? How are we defining the variable number as an actual number? Thanks for your help in advance.

var isEven = function(number) {
  if (number%2 == 0) {
      return true;
  else {
      return false;


number is locally defined. It takes its value from the argument we pass in with the function call.

var foo = function (bar) {
    return "foo" + bar;
console.log(foo("bar"));    // foobar

The function sees the string "bar" in the argument, and refers to that value locally with bar.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.