Created
January 22, 2014 20:45
-
-
Save opheliasdaisies/8567042 to your computer and use it in GitHub Desktop.
responses for codequiz 4: http://www.codequizzes.com/topics/26/quizzes/88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What does the following code print to the console? | |
var person = { | |
name: "Joe Camel", | |
age: 42, | |
status: "dead" | |
} | |
console.log(typeof person); | |
ans: object | |
What does the following code print to the console? | |
var hat = { | |
size: "large", | |
color: "orange" | |
} | |
console.log(hat.size); | |
ans: large | |
What does the following code print to the console. | |
var teddy_bear = { | |
texture: "fluffy" | |
} | |
console.log(teddy_bear["texture"]); | |
ans: fluffy | |
What does the following code print to the console? | |
var fat_joe = { | |
crew: "Terror Squad" | |
} | |
fat_joe.crew = "something"; | |
console.log(fat_joe.crew); | |
ans: something | |
What does the following code print to the console? | |
var pen = {}; | |
pen.ink = "blue"; | |
console.log(pen.ink); | |
ans: blue | |
What does the following code print to the console? | |
var walking_dead = { | |
topic: "zombie apocalypse" | |
} | |
console.log(walking_dead["main_character"]); | |
ans: undefined | |
What does the following code print to the console? | |
var bottle = { | |
contents: function () { return "some fine bubbly" }, | |
color: "green" | |
} | |
console.log(bottle.contents()); | |
ans: some fine bubbly | |
What does the following code print to the console? | |
var yao = { | |
self: function () { return this } | |
} | |
console.log(yao === yao.self()); | |
ans: true | |
What does the following code print to the console? | |
var lebron = { | |
occupation: "basketball", | |
introduction: function () { | |
return "My name is LeBron and I play " + this.occupation | |
} | |
} | |
lebron.introduction(); | |
ans: 'My name is LeBron and I play basketball' | |
What does the following code print to the console? | |
var square = { | |
side_length: 4, | |
area: function () { | |
return this.side_length * this.side_length; | |
} | |
} | |
console.log(square.area()); | |
ans: 16 | |
What does the following code print to the console? | |
var me = { | |
first_name: "Matthew", | |
last_name: "Powers", | |
full_name: function () { | |
return this.first_name + " " + this.last_name; | |
} | |
} | |
console.log(me.full_name()); | |
ans: Matthew Powers | |
What does the following code print to the console? | |
var mug = { | |
capacity: "10 fluid ounces", | |
customer_message: function (desired_size) { | |
if (desired_size > 10) { return "This mug is not large enough for you" }; | |
} | |
} | |
console.log(customer_message(13)); | |
ans: ReferenceError: customer_message is not defined | |
What does the following code print to the console? | |
function global_function () { return "I can be called anywhere" }; | |
var an_obj = { | |
something: global_function | |
} | |
console.log(an_obj.something()); | |
ans: I can be called anywhere | |
What does the following code print to the console? | |
var person = { | |
age: 32, | |
address: { | |
city: "New York", | |
state: "NY" | |
} | |
} | |
console.log(person.address.city); | |
ans: New York | |
What does the following code print to the console? | |
var golf = { | |
type: "sport", | |
clubs: { | |
high_end: "taylor made", | |
low_end: "rusty basement clubs" | |
} | |
} | |
golf.clubs.high_end = "callaway"; | |
console.log(golf.clubs.high_end); | |
ans: callaway | |
What does the following code print to the console? | |
var ideal_scene = { | |
status: "chillin'", | |
location: "somewhere with good waves", | |
thoughts: "bling bling" | |
} | |
delete ideal_scene.thoughts | |
console.log(ideal_scene.thoughts); | |
ans: undefined | |
Describe the value that the zombie variable is assigned to. | |
var zombie = new Object(); | |
ans: zombie is assigned to an empty object. so zombie = {}; | |
What does the following code print to the console? | |
var game = { title: "tic tac toe" }; | |
var same_game = { title: "tic tac toe" }; | |
console.log(game === same_game ); | |
ans: false | |
What does the following code print to the console? | |
var lyric = { lyric: "right now, aight" }; | |
console.log(lyric === lyric); | |
ans: true | |
What does the following code print to the console? | |
var ruff_ryders = { | |
dmx: { | |
birthplace: "Mount Vernon, NY" | |
} | |
} | |
console.log(ruff_ryders.lox.birthplace); | |
ans: TypeError: cannot read property 'birthplace' of undefined | |
What does the following code print to the console? | |
var ruff_ryders = { | |
dmx: { | |
birthplace: "Mount Vernon, NY" | |
} | |
} | |
console.log(ruff_ryders.lox && ruff_ryders.lox.birthplace); | |
ans: undefined | |
What does the following code print to the console? | |
var a = { | |
x: "y" | |
} | |
console.log("x" in a); | |
ans: true | |
What does the following code print to the console? | |
var abc = { | |
zz: "ll" | |
} | |
console.log(abc.hasOwnProperty("zz")); | |
ans: true | |
Add a real_name property to the following dmx object with the value "Earl Simmons". | |
var dmx = { | |
occupation: "rapper" | |
} | |
ans: dmx.real_name = "Earl Simmons"; | |
Add a circumference method to the following circle object that returns the circumference of the circle (Pi equals Math.PI). | |
var circle = { | |
radius: 10 | |
} | |
ans: circle.circumference = function(){ return 2 * Math.PI * this.radius }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment