Project Calculate the Mean and Mode - Test Error

Link to the project: (https://www.codecademy.com/code-challenges/code-challenge-calculate-the-mean-and-mode-javascript)

Hey everyone,
I was making the project of calculating Mean and mode and I’m able to get the results (well at least i believe my code is right) the problem is i can’t pass the test. Every time i get the message "Tests failed to run due to an error: "Looks like your code is not compiling or not being exported with module.exports = statsFinder. Check for a syntax error. ". Check your code and try again."

I’m stuck can’t understand what’s wrong, thanks in advance!

**function statsFinder(array) {**
**  //Mean**
**  let arrayLength = array.length; **
**  let sum = 0;**
**  for (i=0; i<array.length; i+=1) {**
**    sum += array[i];**
**  }**
**  let average = sum / arrayLength;**

**  //Start Mode**
**  let count = {};**
**  let max = 0;**
**  let mode;**
**  **
**  for (i=0; i<array.length; i+=1) {**
**    const value = array[i];**
**    count[value] = (count[value] || 0) + 1; **
**    if (count[value] > max ) {**
**      max = count[value];**
**      mode = value;**
**    }**
**  }**
**  return [average, mode];**
**}**

**console.log(statsFinder([500, 400, 400, 375, 300, 350, 325, 300]))**

**// Leave this so we can test your code:**
**module.exports = statsFinder;**

Hi, looks alright to me. The only problem I see is that you don’t initialize your variable i.

1 Like