- 编程题: 有以下两个变量 num1 和 num2,若两个变量相加等于 15.3,则输出’运算正确’,否则输出’运算错误’
var num1=14
var num2=1.3
if((num1*10+num2*10)/10==15.3){
console.log('运算正确')
}else{
console.log('运算错误')
}
- 编程题, 运算并打印结果
有一篮苹果,两个两个的拿剩一个,三个三个的拿剩一个,四个四个的拿剩一个,五个五个的拿剩一个,六个六个的拿剩一个,七个七个的拿,能拿完,请问这篮子里有多少个苹果?//2456余1;7整除
for(var i =0;i<=100;i++){
var sum=60*i+1;
if(sum%7 === 0){
console.log(sum)
}
}
- 写出下面式子的值 ```javascript typeof 100 //number typeof true //Boolean typeof(undefined)//undefined typeof({})//object typeof( [1,2] )//object typeof(NaN)//number typeof(null)//object
4. 编程题: 多重判断<br />作业要求: 在屏幕输入一个数字,确定后弹出相应的年龄段
年龄划分: “0-6岁为婴幼儿; 7-12岁为少儿; 13-17岁为青少年; 18-45岁为青壮年; 46-69岁为中年; 69岁以上为老年
var age = prompt(‘请输入你的年龄’) if(age <=6){ alert(‘婴幼儿’) }else if(age <=12){ alert(‘少儿’) }else if(age <=17){ alert(‘青少年’) }else if(age <=45){ alert(‘青壮年’) }else if(age <=69){ alert(‘中年’) }else{ alert(‘老年’) }
5. 写出下面式子的值
‘1.23’ == 1.23 //ture
0 == false //ture
null == undefined //ture
NaN == NaN //false
1 == ‘1’ //ture
1 === ‘1’ //false
1 + ‘2’ === ‘1’ + 2 //ture
1 + true === false + 2 //ture
1 + null == undefined + 1 // false
4 === ‘4.00’//true
0 == false //ture
0 == null //false
null == false // false
‘1.23’ == 1.23 //true
0 == false //true
null == undefined //true
NaN == NaN //false
‘a’ - ‘b’ == ‘b’ - ‘a’ false 4 == ‘4.00’ true 4 === ‘4.00’ flase 0 == false t 0 == null f null == false f ‘1.23’ == 1.23 t 0 == false t null == undefined t NaN == NaN f 1 == ‘1’ t 1 === ‘1’ f 1 + ‘2’ === ‘1’ + 2 t 1 + true === false + 2 t 1 + null == undefined + 1 f ‘a’ - ‘b’ == ‘b’ - ‘a’ f 4 == ‘4.00’ t 4 === ‘4.00’ f 0 == false t 0 == null f null == false f
加减作业题
var score = 50;
var grade = ‘7’;
score + 10; 60
score + ‘10’; 5010
score + null; 50
score + undefined; nan
score + NaN; nan
score + 10;
grade + NaN; “7NaN”
var num1 = 8;
var num2 = ‘8’;
num1 - num2; 0
num1 - ‘web01’; NaN
num1 - null; 8
num1 - undefined; NaN
num1 - true; 7
num1 - false; 8
num1 - num2; 0
```