我需要在其他语句中添加年龄小于16岁的第二个人来返回它的字符串。我该如何添加?
function canDrive(name, age) {
var person = {
name: "Stefano",
age: 24,
};
if (person.age => 16) {
return name + " is old enough to drive.";
}
else {
return name + " is not old enough to drive.";
}
}
答案 0 :(得分:0)
你不仅可以从人身上获得年龄。这里的人是不可变的对象
if(person.age >= 16) { } else { }
答案 1 :(得分:0)
>=
。''
。
function canDrive(name, age) {
if (age >= 16) {
return name + " is old enough to drive.";
} else {
return name + " is not old enough to drive.";
}
}
console.log(canDrive('ram',12))
console.log(canDrive('vj',22))