這是我的電梯PROGRAMM:福爾循環不正常工作
var person = {
name: "Roman",
position: 7,
goal: 9
};
var lift = {
getPosition: function() {
var x = Math.floor((Math.random() * 10) + 1);
return x;
}()
};
console.log("Ok " + person.name + "! You are at " + person.position + " floor");
console.log("Lift is at " + lift.getPosition + " floor");
if (lift.getPosition > person.position) {
for (i = lift.getPosition; i >= person.position; i--) {
console.log(i);
}
} else if (lift.getPosition < person.position) {
for (i = lift.getPosition; i <= person.Position; i++) {
console.log(i);
}
}
console.log("Please enter inside!");
有關提高電梯無法正常工作循環。升降但不升高。什麼是錯的?
如果其他人缺少等於條件。 – MrMadsen
提升對象內部的函數是否被調用並返回一個值? – code