Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to divide total score by amount of input items

I would like to create a dynamic calculator with several amount of input items (user decides)

Let say, I want to sum all the input numbers up and then divide by amount of all inputs that took part in calculating.

How can I do it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried to find sth on YouTube and another posts but unfortunately didnt found. 🙁

>Solution :

maybe try to save all numbers in an array then add them up and devide by the lenght of array

let array = [NUMBERS]
let final = 0
array.forEach(e => {
  final += e
});
final /= array.lenght
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading