Help me find error

Help me to check error

<!DOCTYPE html>
<html>
 <head>
  <script type = "text/JavaScript">
   var count, str, intcount, intnum, num;
   str="";
   for(intcount = 0; intcount < 5 ; ++intcount){
    num = window.prompt("Enter integer" + (intcount+1) + ":", "");
    intnum = parseInt(num);
    if(intnum % 2 ==0){
     str += intnum + "";
     count = count + 1;
    }
   }
   window.alert("There are " + count + " even number: " + str);  
  </script>
 </head>
 <body>
 </body>
</html>  

What is the error?

Use any browser to run it and you will find error.

It worked for me. What error are you seeing?

There are NaN even number. If you key in even number, it will display how many even number instead of NaN .

Thanks. What is the value of count before the code adds 1 to it;

I miss type count=0, I already have solution. Thanks for your reminder.

1 Like

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