OneBite.Dev - Coding blog in a bite size

add two numbers in Javascript

Code snippet on how to add two numbers in Javascript

let num1 = 5;
let num2 = 8;

let sum = num1 + num2;

console.log(sum);

This code adds two numbers together. First, we define two variables, “num1” and “num2”, and assign them the values 5 and 8, respectively. Then, we create a new variable, “sum”, that stores the sum of the two numbers (5 + 8). Finally, we log the result to the console.

javascript