# How to add all class percentage totals together to get mean average?

https://w.trhou.se/2k0sy69xol

Been told by treehouse teacher to experiment to gain experience. So I'm creating my own programs to help myself learn so one day I will understand the DOM.

Hi jas0n!

I hope all is well for you and yours!

The mean is the average of the numbers. It is easy to calculate: add up all the numbers, then divide by how many numbers there are. In other words, it is the sum divided by the count.

From:

https://www.mathsisfun.com/mean.html

And here is a JS example using array.reduce to total the scores (percentages):

```var percentages = [84, 77, 93, 68, 79, 85];
const total = percentages.reduce((total, val) => {
}, 0);
const mean = total/percentages.length; // sum/count
console.log(mean);
```

Logged to console: 81

```84 + 77 + 93 + 68 + 79 + 85 = 486

486/6 = 81
```

BTW, I got my first Covid shot yesterday!?!

I hope that helps.

Stay safe and happy coding!

Hmm I got to think how to incorporate that into html, thanks though, am I ok doing function this way:-

var percentages = [84, 77, 93, 68, 79, 85];
function mypercentages(total, val) {
var sum = percentages.reduce;
};
var meanAve = total/percentages.length; // sum/count
console.log(mean);

I did the function this way because I find it easier to understand, still same result. Hope you and family are well.

Can I just ask you, if like me you were repeatedly failing to understand JavaScript would you think it would be better to be a web designer instead of struggling always with JavaScript? I mean its possible to get a web designer job isn't it?

(I do recommend watching the whole videos, though, to learn higher-level ES6 array functions well/better!?!)

I hope that helps.

Stay safe and happy coding!

We are well!!!

U2 (you and yours)!!!

:)

Thanks for your help, I've switched tracks to do web design, I'd hopefully learn javaScript once working with web design in the future. Take care. Jas0n.

To answer your Web designer vs Web developer question, I'll just throw out a few thoughts:

I think it depends on your temperament. Do you enjoy graphics over coding/algorithms?

https://elementor.com/blog/web-designer-vs-web-developer/

I first got into programming because I took an electronic music class and was able to use a computer to sequence music, which I really enjoyed. I thought I enjoyed it because I liked music, but I later realized I like the power programming allows you to make something behave the way YOU WANT IT TOO!?!

I realized I've always had an admiration for systems and program flow.

For example, I have always liked setting up dominoes in a big pattern where you knock the first one down and they all fall down in succession. In effect, it's a (very simple) program - you start it, and if you set it up right - it runs all the way to the end.

Or the mousetrap game:

Also:

I've thought stuff like these were interesting my whole life!?!

(All crude versions of computer programs.)

For a long time, I fought becoming a programmer (I wanted to be a ROCK STAR - I play drums!?!), but my. father was an electrical engineer and my brother has been a Java developer for over 30 years, so it was inevitable that I gravitate towards programming - it's in my blood!?!

Also, I've always been good at math, too (going as far as scientific calculus in college) and music, math, and programming are very similar (in the way you have to process information and think logically and linearly). All three use the same kind of right/left brain balance.

Regardless, I still think you should crush HTML, CSS, and Javascript as best you can. Just know it will get easier.

I hope that helps.

Stay safe and happy coding!