Back to Games

Game Challenge: Create a Function

Welcome to the JavaScript Challenge! Here, you’ll write a function to add two numbers together.

Task: Write a function that takes two numbers and returns their sum.

Enter your code below:

JavaScript Basics

Variables

Variables hold data. Use let or const to declare a variable. For example:

let myNumber = 5;

Functions

A function is a block of code designed to perform a task. Create a function with function followed by a name and parentheses. Example:


function add(a, b) {
  return a + b;
}