How to find prime number in javascript?

I need to know how to find prime number from 1 to 100. For this problem what kind of step should I take?

for(let i = a; i <= 10; i++){

    if(i / i + 1 == 1){

        console.log(i + ' is a prime number.');

    }

    else{

        console.log(i + ' is not a prime number');

    }

}

I did this. but I can’t implement the condition. will you help me anyone to find out the condition or this problem solution?

What you need is a formula to check whether the current number in this loop is a prime number or not.
Let’s Create a function to check if a number is a prime number.

function isPrime(num) {
    for(let i = 2; i <= Math.sqrt(num); i++){
        if(num % i === 0) return false; 
    }
    return num > 1;
}

Then in the loop, we can call the function to find all prime numbers.

for(let i = 2; i <= 100; i++){
    if( isPrime(i) ) {
        console.log(i + ' is a prime number.');
    }
    else{
        // console.log(i + ' is not a prime number');
    }
}

Hope that solves the problem.

More simple and easy to understand.

function isPrime(num) {
  for(var i = 2; i < num; i++)
    if(num % i === 0) return false;
  return num > 1;
}

You are doing a lot of extra loops. For example, if the num is 100 or 1000 then the loop will run 1000 times. But Math.sqrt(1000) is only 31.
If you want to keep the function more simple you can try the function below

function isPrime(num) {
    for (let i = 2; i * i <= num; i++)
        if (num % i === 0)
          return false; 
    return num > 1;
}