Ask coding questions

← Back to all posts
Practicing toy problems
longevitytina (0)

Hey everyone,

I am attempting to work on toy problems, such as codewars, etc. Even on the most basic fundamental questions, I am struggling very much. I know that a big problem is needing more experience with syntax. I'm curious if anyone can recall their experience in approaching this situation when you were a beginner.

For example, the problem I was attempting to solve:

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){
//TODO : calculate the downwar rounded average of the marks array
function getAverage(marks){
return Math.floor(marks.reduce((sum, x) => sum + x) / marks.length);

I knew that I needed to sum the array, and divide by the number of indexes.

I spent quite a chunk of time searching through the for JS, only to be trying out solutions with syntax errors.