Functions in JavaScript: receiving, returning, and reusing
Create and call functions, use parameters and return values, and understand their scope. Learn simple arrow functions and organize a shopping calculator into reusable responsibilities.
- Level
- Beginner
- Lessons
- 5
- Learning steps
- 73
Your lesson journey
Each lesson has a purpose. Follow the order or revisit an idea you want to practise.
5 of 5 lessons shown
The numbers show the lesson order, not your progress.
What you will learn
Recognize opportunities for reuse and define functions with a clear responsibility. Distinguish declaring a function from calling it and follow an invocation's path. Associate parameters and arguments by position and use defaults with their limitations. Return values with return and use them in variables, expressions, and other calls. Distinguish console output, explicit return values, and returning undefined. Explain the local scope of parameters and variables and access to outer names. Write function expressions and simple arrow functions with implicit or explicit returns. Build and check a five-function calculator and fix errors involving return values, arguments, and scope.
Before you start
Complete courses 01 through 09 of Programming Fundamentals or know their contents. The course uses JavaScript in the console, let, const, basic types, operators, conditionals, loops, block scope, and manual checks. No experience defining your own functions is required. Exercises use fictional data and simple values without installations.
About this course
Read the full description
Course 10 of Programming Fundamentals from Código con Criterio. Across five lessons, you will progress from a welcome message without parameters to five functions that collaborate to calculate and display purchases.
Codi guides progressive examples, call-and-return diagrams, activities with hints, and labs. The course distinguishes definition and invocation, parameters and arguments, displaying and returning, local data and results received outside. Defaults are practiced with omitted arguments, undefined, and explicit values.
Arrow functions are introduced after understanding function and return. Expression and block bodies are compared, with clarification that they are not completely equivalent to traditional functions. The course does not explore this, scope capture, or internal mechanisms in depth.
The challenge defines a calculator with a subtotal, percentage discount, total, promotional check, and summary. It includes two scenarios, a complete reference, and fixes for return values, arguments, and scope. Activities check understanding; free-form code and personal explanations are not automatically corrected.
No installations, arrays, objects, callbacks, higher-order functions, recursion, or asynchronous programming are required. Examples are independent programs; use a new context if your tool retains previous declarations.
This course is part of these learning paths
Follow the suggested order or take this course on its own.