Why can't I factorialize this number?

Tell us what’s happening:
I don’t understand why I’m getting a syntax error at the else statement

  **Your code so far**

function factorialize(num) {
if (num = 1) or (num = 0); {
return 1}
else {
return num * factorialize(num-1)

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36 Edg/94.0.992.47

Challenge: Factorialize a Number

Link to the challenge:

Hi. For starters, in your if-statement, you’re using an assignment operator ( = ) instead of an equality operator ( == ).

Secondly, the condition(s) you are checking should all be between one pair of parentheses and you should use the logical OR operator ( || ) like so:

if ( condition A  || condition B ) {
      // do stuff here;

Finally, please always enclose your code between a pair of three backticks ( ``` ) for readability. Cheers

1 Like

There are a lot of syntax errors in this code.
You have two sets of parenthesis after the if keyword. or isn’t a keyword. You have random stray semicolons.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.