Snippets Collections
function firstFunction() {
  // parent function
  const x = 100; // parent variable / cant be used inside the child function

  function secondFunction() {
    const y = 60; // child variable / cannot be called in the parent function
    return y + x; // return calculation to the child function
  }

  return secondFunction(); // evoke the second function by returning it to the parent function
}

console.log(firstFunction()); // call the parent function
star

Mon Apr 29 2024 08:36:24 GMT+0000 (Coordinated Universal Time)

#functions #nesting #scope

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension