Printing all the prime numbers between 0 and 100

I’d appreciate a lot if you could point out what I am doing wrong with my code.

https://www.codecademy.com/courses/fizzbuzz/0/6?curriculum_id=4f4bdd96848740000300026a#
ReferenceError: Invalid left-hand side in assignment

for (var counter = 0; counter <= 100; counter = counter + 1) 
{
    for (var x = 2; x < counter; x = x + 1)
    {if(counter % x = 0)
        {
        console.log(counter);
        }
    }
    
}

Very many thanks,
Masa

This post was flagged by the community and is temporarily hidden.

Thank you. I could fixed the error. But my code is not correct yet, to get prime numbers between 0 and 100.

for (var counter = 0; counter <= 100; counter = counter + 1) 
{
    for (var x = 2; x < counter; x = x + 1)
    {if(counter % x != 0)
        {
        console.log(counter);
        }

Your dan’t closed your curly brackets. You have only if(counter % x != 0) closed properly. Your code should look like:

for (var counter = 0; counter <= 100; counter = counter + 1) {
    for (var x = 2; x < counter; x = x + 1) {
        if (counter % x != 0) {
            console.log(counter);
        }
    }
}

You should rethink your algorithm. Now it’s printing all numbers (multiple times). For finding prime number you could read about Sieve of Eratosthenes, I think it is one of the most efficient ways to find all of the smaller primes.