Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the average of three numbers by javascript

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the javascript how to achieve the average of three numbers of related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this javascript article on how to achieve the average of three numbers will have a harvest, let's take a look.

Methods: 1, use the "+" operator to add and sum the three numbers, and assign a value to the variable "sum", syntax "sum= numeric value 1 + numeric value 2 + numeric value 3"; 2, use the "/" operator to divide the sum of the three numbers by 3, and assign the value to the variable "ave", syntax "ave=sum/3"; 3, output the value of the variable "ave".

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Javascript realizes three numbers to find the average.

The average is the sum of all the data in a set of data divided by the number of the set of data.

We just need to add up the three numbers and divide by 3.

For example, there are three numbers: 1, 2, 3, in terms of their average:

Implementation code:

Var arecrophe brecrum beacon Ave pincushion aplomb (ave), pachyderma pachyma, pachydermus,

This is to know the specific number of data, if you do not know how to find the average?

We can use arrays.

/ / array to find the sum of elements function getSum (arr) {var sum=0,ave=0,i=0; for (iSum)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report