<script>
while (R = prompt('请输入球的半径值')) {
if (!(isNaN(R))) {
console.log("球体的体积" + 3 / 4 * Math.PI * Math.pow(R, 3))
break;
}
}
</script>
<script>
let mencnt = 0, womencnt = 0,
str = prompt('请输入字符串')
for (let index = 0; index < str.length; index++) {
const element = str[index];
if(!(isNaN(element))){
mencnt ++;
womencnt += parseInt(element)
}
}
console.log("男女比例" + mencnt, womencnt)
</script>
<script>
function fun(n){
n = n + "";
return n.split("").reverse().join("");
}
console.log(fun(123))
</script>
<script>
var person = {
name: "Tom",
age: 18,
sex: "man",
stuid: '123456',
eat() {
console.log("我最喜欢吃的食物是: xxx")
},
play() {
console.log("我最喜欢欢玩的游戏是: xxx”")
}
};
eat = person.eat();
play = person.play();
console.log(person.name)
</script>
<script>
function Stu(name, sex, age, stuid) {
this.name = name
this.sex = sex
this.age = age
this.stuid = stuid
}
var stu02 = {
eat() {
console.log("我最喜欢吃的食物是: xxx")
},
play() {
console.log("我最喜欢欢玩的游戏是: xxx”")
}
};
var stu = new Stu('Tom', 'man', 18, '123456')
</script>
原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈