Answers for "function expression and function declaration"

3

js function expression

const plantNeedsWater = function(day){
  if (day === 'Wednesday'){
    return true;
  } else{
    return false;
  }
}

console.log(plantNeedsWater('Tuesday'))
Posted by: Guest on August-07-2020
2

function expression

const getRectArea = function(width, height) {
  return width * height;
};

console.log(getRectArea(3, 4));
// expected output: 12
Posted by: Guest on July-05-2020
1

javascript function expression

const mul = function(x, y){
    return x * y;
}; //semicolon needs to be there as it is expression

console.log(mul(10, 20));
Posted by: Guest on August-10-2020
0

function expression and function declaration

// Function Declaration
function add(a, b) {
	return a + b;
}
console.log(add(1,2)); //3

// Function Expression
const add = function (a, b) {
	return a + b;
};

console.log(add(1,2)); //3
Posted by: Guest on March-06-2021

Code answers related to "function expression and function declaration"

Code answers related to "Javascript"

Browse Popular Code Answers by Language