DESCRIPTION:
It's the academic year's end, fateful moment of your school report. The averages must be calculated. All the students come to you and entreat you to calculate their average for them. Easy ! You just need to write a script.
Return the average of the given array rounded down to its nearest integer.
The array will never be empty.
코드
function getAverage(marks){
return Math.floor(marks.reduce((a, b) => a + b, 0) / marks.length);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Valid Braces (6 kyu) / JavaScript (0) | 2023.02.24 |
---|---|
[Codewars] Count by X (8 kyu) / JavaScript (0) | 2023.02.23 |
[Codewars] Array plus array (8 kyu) / JavaScript (0) | 2023.02.21 |
[Codewars] Rock Paper Scissors! (8 kyu) / JavaScript (0) | 2023.02.20 |
[Codewars] Total amount of points (8 kyu) / JavaScript (0) | 2023.02.19 |
댓글