JavaScript Code

How to find average of two numbers?

Problem Statement

given two numbers, write a JavaScript program to find the average of these two numbers


to find the average of two numbers, find their sum using addition operator, and then divide the sum by 2 using division operator

(a + b) / 2


given numbers are num1 and num2. we find the average of num1 and num2

let num1 = 4;
let num2 = 8;
let sum = num1 + num2;
let average = sum / 2;