Technical question


#1



i just wanna know why we didn't take any parameters in the function .. what does it mean .. and when can i dont put any parameters in the function ?


var hungry = true;
var foodHere = true;

var eat = function() {
  // Add your if/else statement here!
  if(hungry && foodHere) {
      return true;
  } else {
      return false;
  }
};


#2

Some functions do something and don't require any inputs (parameters).

function print_error_msg() {
    console.log("An error has occurred.");
}

print_error_msg();    // An error has occurred.

#3

aha .. ok thank you for your answer ^_^

can u give another example so i could understand it more <3


#4

This function does require inputs upon which it can act:

function addab(a, b) {
   console.log(a + b);
}

addab(35, 7);    // 42
addab(6, 36);    // 42

This one takes a single parameter:

function squarex(x) {
    console.log(x * x);
}

square(2);    // 4
square(7);    // 49
square(33);   // 1089

Here is another with no parameter:

function helloWorld() {
    console.log("Hello World!");
}

helloWorld();    // Hello World!