Blogger Information
Blog 10
fans 0
comment 0
visits 6733
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0506while循环,对象字面量函数方法作业
abing的博客
Original
644 people have browsed it
//while 循环输出1-10的奇数有哪些

var sum=10;    //设置数值的范围
var i=0;   //用I作为循环判断条件
while(i<=sum)   //循环条件
{
if(i%2!=0)  //if判断取模运算不为0的数值有哪些
{
console.log(i);
}
i++;  //while 循环增加一直到i<=sum 跳出while 循环
}

//对象的字面量输出手机的信息
var mymoilb={};   //创建一个对象,内容为空      
mymoilb.name='华为'; //给对象增加一些属性
mymoilb.RAM=32;
console.log('我喜欢的手机型号是' + mymoilb.name,'手机的内存是' + mymoilb.RAM + 'G');  //调用对象里的属性显示出来!



//用函数方法计算三个数的合
var add = function(a1,a2,a3) { //声明一个函数add
return a1+a2+a3;  //返回的方法是加法运算
}
console.log(add(3,2,3));  //传入三个参数,返回到函数add的加法计算


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