Question about a Practice Question

The problem I’m having is on this assignment: Practice JavaScript Syntax: Arrays, Loops, Objects, Iterators | Codecademy

I added some tests at the bottom of the function to see what the results would be.

This is the solution it gives

This is the solution I put, but it gives me an error and says “it likely has a syntax error”, however nothing shows up in the console showing that I have an error.

It says this at the top:

// returns 720 because 6 * 5 * 4 * 3 * 2 * 1 = 720

However, the solution that the practice problem gives makes factorial(6) return 5040. I’m not sure if I misread something or if I’m missing a step. Any assistance is very much appreciated! :slight_smile:

Also adding onto this, when I search up in google what the factorial of 1 is it says it’s 1. However, the practice problem seems to be testing the equation to make sure the factorial of 1 is not equal to 1? I don’t really understand why it’s doing that.

actually, both the exercise solution and your code are wrong. factorial 6 is indeed 720, you are right in that regard.

but you missed the zero edge case:

// Write function below
const factorial = (num) => {
  for (let i = num - 1; i >= 1; i--){
    num *= 1

  return num


what do you think the factorial of zero is?

1 Like