Can you tell what it's wrong with me code

javascript

#1

I am doing a To-do list and i need to create a list of image with rewards that are given by the number of completed tasks by the user.
I don't know what it's wrong with my code. I am thinking in doing an array with the awards with would be a lot easier and pratical.

function main() { 

   function rewards()
    
    {
        var done = get_done();
        var ndone = done.length;
         var award= "";
       
        
  for (var check=0; check < ndone; check++)
      
  {
  if(check === 10 || 20 || 30)
  {
 award = award  + "<li class='list-group-item'><img src='images\'" + check + "'%20tarefas.png'></img></li>"; 
//the image is the award 
 
  }    
    }
        
        document.getElementById('awardlist').innerHTML = award;
  }
    
    return rewards();
}

#2

if(check === 10 || 20 || 30)

This is going to trip you up.

Statements are treated as separate when using comparison operators, which means that each one is going to return true or false. Another way of writing that statement is:

"If check is the same as 10; or if 20 is true; or if 30 is true"

In the above, 20 and 30 by themselves will always return true. Now see how the following statement translates:

if (check === 10 || check === 20 || check === 30)

"If check is the same as 10; or if check is the same as 20; or if check is the same as 30"

In this case, check is checked each time against the number.

You may find however that this becomes tedious if you want to start using more numbers (40, 50, 60, etc). In this case, you could consider using an array of values and checking if your check value matches any of them.


#3

You're right it's kind of silly using a statement without declaring it's variable.
I will try your method, i just needed to check 10, 20 and 30 but for longer values i will do differentlly.
Thank you =D