javascript基本语法
1、if语句简单实例:
输入分数筛选是否合格
<script type="text/javascript"> var socer = parseInt(window.prompt('input')); if (socer > 90 && socer <= 100) { document.write('优秀'); } else if (socer > 80 && socer <= 90) { document.write('合格') } else { document.write('不合格'); } </script>
2、for循环语
打印10次a
方法一: <script type="text/javascript"> for (var i = 0 ; i < 10 ; i++){ document.write('a'); } </script>
方法二: <script type="text/javascript"> var i = 1; count = 0; for (; i ;) { document.write('a'); count ++; if (count == 10) { i = 0; } } </script>