2016年3月23日 星期三

Multiplication table 九九乘法表

Solution 1: 

Review: parseInt(), var num, prompt(string, value);

Code:

<html>
   <head>
        <title> multiplication table</title>
   </head>
   <body bgcolor=red>
                <script type="text/javascript">
      var num;
   num = prompt("Enter a number:","0");  //prompt(string,value)
    num = parseInt(num);                            // to see if things you input a num or NaN
for(i=1; i<10; i++){
  document.write(i+"*"+num+"="+i*num+"<br><br>");
}
</script>
    </body>
</html>
   
Solution 2:

Codepen: Check here    I don't quite get this

沒有留言:

張貼留言