Javascript if statements not working [duplicate]

You’re assigning with =. Use == or ===.

if( 0 == number ){

  text.value = "You didn't enter a number!";
}

Also, be wary of your brace placement. Javascript likes to automatically add semicolons to the end of lines. Source.

Leave a Comment