# JavaScript Program To Find Average of 3 Numbers

In this post, we will learn how to find the average of 3 numbers using JavaScript.

Average of numbers is simply the sum of the numbers divided by the total number of elements in the set.

Average = Sum of all Elements / Total no. of Elements

We will be using the above formula to compute the average of 3 numbers.

So, without further ado, let’s begin this tutorial.

Contents

## JavaScript Program To Find Average of 3 Numbers

```//JavaScript Program To Find Average of 3 Numbers
//Take User Input
var a = parseInt(prompt("Enter First Number: "));
var b = parseInt(prompt("Enter Second Number: "));
var c = parseInt(prompt("Enter Third Number: "));

//Calculate Average
var average = (a + b + c) / 3;

//Display Output
console.log("The average of three numbers: " + average);
```

Output

``````Enter First Number: 7
Enter Second Number: 8
Enter Third Number: 15
The average of three numbers: 10
``````

## How Does This Program Work ?

``````var a = parseInt(prompt("Enter First Number: "));
var b = parseInt(prompt("Enter Second Number: "));
var c = parseInt(prompt("Enter Third Number: "));
``````

In this program, the user is asked to enter the values of three numbers.

``````//Calculate Average
var average = (a + b + c) / 3;
``````

Average is calculated using the formula = Total Sum / Total no. of elements.

``````//Display Output
console.log("The average of three numbers: " + average);``````

Finally, the average of three numbers is printed on the screen using the console.log() method.

## Conclusion

I hope after going through this post, you understand how to find the average of 3 numbers using JavaScript.

If you have any query regarding the program, feel free to contact us in the comment section. We will be delighted to help you.