Jump to content

alert error


rekha

Recommended Posts

Hi

 

Why this following code did not alert the number 8?

<script language="JavaScript">
        for (j=0; j < 9; j++){
       for (i=0; i < 9; i++){
          var numToString = parseInt(j+""+i);
         alert(numToString);
        }
      }
      </script>

 

Regards

Rekha

http://hiox.org

Link to comment
https://forums.phpfreaks.com/topic/87366-alert-error/
Share on other sites

Hi,

 

I want to know why the number 8 is not alerting when run the code

 

<script language="JavaScript">
        for (j=0; j < 9; j++){
       for (i=0; i < 9; i++){
          var numToString = parseInt(j+""+i);
         alert(numToString);
        }
      }
      </script>

 

Regards

Rekha

http://hiox.org

Link to comment
https://forums.phpfreaks.com/topic/87366-alert-error/#findComment-447666
Share on other sites

thats a problem with parseInt it does not parse 08 and 09 properly use parseFloat instead following is the code, also I changed some things...

 

<script language="JavaScript">
        for (j=0; j < 9; j++){
       for (i=0; i < 9; i++){
          var numToString = parseFloat(j.toString()+i.toString());
         alert(numToString);
        }
      }
</script>

Link to comment
https://forums.phpfreaks.com/topic/87366-alert-error/#findComment-447668
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.