Blogger Information
Blog 29
fans 0
comment 1
visits 19838
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
javascript第一课
风清扬
Original
989 people have browsed it

12月16号作业
1、javascript变量、函数的定义
var num1 = 30;/变量声明/
function myFunction(a, b) {
函数的定义
}
alert(num1)//输出

2、javascript流程控制if else switch

<script type="text/javascript">
var num1 = 30;/变量声明/
var num2 = 6;

var score=60;
var myscore=90;
if(myscore>90){
alert(‘优秀’);
}else if(myscore<=90 && myscore>70){
alert(‘一般’);
}else if(myscore<=70 && myscore>60){
alert(‘及格’);
}
else{
alert(’不及格’);
}


var myscore=90;
switch(myscore){
case myscore>90:
alert(‘优秀’);
break;
case myscore<=90 && myscore>70:
alert(‘一般’);
break;
case myscore<=70 && myscore>60:
alert(‘及格’);
break;
}













</script>

3、javascript三种循环

for (i = 0; i < cars.length; i++) {
text += cars[i] + “<br>“;
}

<script type="text/javascript">
var i = 1;
var result = 0;
while(i<=100){
result=result+i;
i++;
}
alert(result);
</script>

<script type="text/javascript">
var i = 0;
var result = 0;
do{ i++;
result=result+i;
}while(i<100) alert(result); </script>

4、数据类型转换:parseInt、isNaN函数的使用

  1. var a='12';
  2. alert(parseInt(a));//字符串转数字
  3. if isNaN(a){
  4. alert('转换失败')
  5. }
Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post