Home/Tutorials/JavaScript/Functions Basics

0 of 3 saved

JavaScript5 min read

Functions Basics

Read this chapter, write the program on this page, then pass a short check to open the next one.

Declare and call functions.

Functions Basics

Functions group reusable steps. They take parameters and can return a value.

  • function name() {} is a declaration (hoisted).
  • const fn = function() {} is an expression.
  • Always return explicitly when you need a value.
function add(a, b) {
  return a + b;
}
console.log(add(2, 3));

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.