If / else


#1


https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/1?curriculum_id=506324b3a7dffd00020bf661#


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;
  }
};


#2

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.


#4

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