Return Statement


function sum(a, b) {
  return a + b;
  console.log("hello");
}
let s = sum(3, 4);
let s2 = sum(sum(3, 5), 8);
console.log(s2);
console.log(s);

function isAdult(age) {
  if (age >= 18) {
    return "adult";
  } else {
    return "child";
  }
}
console.log(isAdult(23));




Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code