Untitled diff

Created Diff never expires
21 removals
50 lines
46 additions
48 lines
// Define variables
// Define variables
var output = document.getElementById("message");
var output = document.getElementById("message");
var movies = document.getElementById("movies");
var object = document.getElementById("object");
var BR = "<br>";
var BR = "<br>";
var makeBreakfast;
var mood;
var energyLevel;
var doWork;
var powerOn;
var command;
var duration;
var quitWork;


// Define robot object
// Define robot object
var robot = {
var robot = {
material: "titanium",
material: "titanium",
mood: "happy",
mood: "happy",
energyLevel: 100,
energyLevel: 100,
powerOn: false,
powerOn: false,
command: "Sweeping the floor",
command: "Sweeping the floor",
duration: 10,
duration: 10,
favoriteMovies: ["2001: A Space Odyssey", "The Terminator", "I, Robot", "WALL-E", "Short Circuit", "Forbidden Planet"]
favoriteMovies: ["2001: A Space Odyssey", "The Terminator", "I, Robot", "WALL-E", "Short Circuit", "Forbidden Planet"],
};

makeBreakfast: function (newMood) {

this.mood = newMood;
makeBreakfast = function (newMood) {
if (this.mood === "Happy") {
mood = newMood;
output.innerHTML += "Here are your waffles and milk, master." + BR;
if (mood === "Happy") {
} else {
output.innerHTML += "Here are your waffles and milk, master." + BR;
output.innerHTML += "Here is your burnt toast and lukewarm water, master." + BR;
} else {
this.energyLevel = 50;
output.innerHTML += "Here is your burnt toast and lukewarm water, master." + BR;
}
energyLevel = 50;
},
}
doWork: function () {
};
if (!this.powerOn) {
doWork = function () {
this.powerOn = true;
if (!powerOn) {
output.innerHtml += "My current task is: " + this.command + ". Duration: " + this.duration + " minutes." + BR;
powerOn = true;
}
output.innerHtml += "My current task is: " + command + ". Duration: " + duration + " minutes." + BR;
},
}
quitWork: function () {
};
if (this.powerOn) {
quitWork = function () {
this.energyLevel = 90;
if (powerOn) {
this.powerOn = false;
energyLevel = 90;
this.command = "Taking a nap";
powerOn = false;
}
command = "Taking a nap";
}
}
};
};


// Make robot do housework
// Make robot do housework
doWork();
robot.doWork();
quitWork();
robot.makeBreakfast('happy');
robot.quitWork();
for(var i = 0, l = robot.favoriteMovies.length; i < l; i++) {
movies.innerHTML += robot.favoriteMovies[i] + BR;
}
object.innerHTML = JSON.stringify(robot);