In JavaScript, functions are one of the fundamental building blocks. A function is a block of organised, reusable code to perform a single task or calculate a value. Functions can be passed one or more arguments and can return a value at the end of their execution.

The example below contains a function that takes in 2 values and returns the sum of those numbers:

Mariola P

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store