var name="张三";
var age="21";
var sex="男";
var job="学生";
var address="江苏南京";
var phone="1234567";
document.write("姓名:"+name+"<br>");
document.write("年龄:"+age+"<br>");
document.write("性别:"+sex+"<br>");
document.write("职业:"+job+"<br>");
document.write("住址:"+address+"<br>");
document.write("电话:"+phone+"<br>");
var name =prompt("请输入您的姓名:");
var HTML=prompt("请输入您的HTML成绩:");
var CSS=prompt("请输入您的CSS成绩:");
var JavaScript=prompt("请输入您的JavaScript成绩:");
var name2 =prompt("请输入您的姓名:");
var HTML2=prompt("请输入您的HTML成绩:");
var CSS2=prompt("请输入您的CSS成绩:");
var JavaScript2=prompt("请输入您的JavaScript成绩:");
console.log("姓名\t\tHTML\t\tCSS\t\tJavaScript");
console.log(name+"\t\t"+HTML+"\t\t\t"+CSS+"\t\t"+JavaScript);
console.log(name2+"\t\t"+HTML2+"\t\t\t"+CSS2+"\t\t"+JavaScript2);
var num1=3;
var num2=8;
console.log("交换前的值:","num1:"+num1,"num2:"+num2);
//方法1:使用临时变量进行交换
var temp=num1;//3
num1=num2;//8
num2=temp;//3
console.log("交换后的值:","num1:"+num1,"num2:"+num2);
//方法2:使用加减运算
var num1=3;
var num2=8;
num1=num1+num2;//11
num2=num1-num2;//3
num1=num1-num2;//8
console.log("交换后的值:","num1:"+num1,"num2:"+num2);
//方法3:数组的解构赋值
var num1=3;
var num2=8;
[num1,num2]=[num2,num1];
console.log("交换后的值:","num1:"+num1,"num2:"+num2);
var name=prompt("请输入姓名:");
var grade=prompt("请输入成绩:");
var grade2=Number(grade)+5;
console.log("姓名:"+name+"\t\t成绩:"+grade);
console.log("老王的成绩:"+grade2);
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明原文出处。如若内容造成侵权/违法违规/事实不符,请联系SD编程学习网:675289112@qq.com进行投诉反馈,一经查实,立即删除!