From 067b6cc1d6baf0da7fcb79fd831f7b696baf10bc Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Fri, 15 Jan 2016 13:35:10 +0000 Subject: [PATCH] Add and addtional example code and fix the console output This commit: * Adds an addtional example to the challenge Waypoint: Accessing Objects Properties with Variables * Adds the tail to display the console output Tested locally. Closes #6112 --- .../basic-javascript.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/challenges/01-front-end-development-certification/basic-javascript.json b/challenges/01-front-end-development-certification/basic-javascript.json index a3ab766538..88908cc999 100644 --- a/challenges/01-front-end-development-certification/basic-javascript.json +++ b/challenges/01-front-end-development-certification/basic-javascript.json @@ -3221,6 +3221,8 @@ "Another use of bracket notation on objects is to use a variable to access a property. This can be very useful for iterating through lists of the object properties or for doing the lookup.", "Here is an example of using a variable to access a property:", "
var someProp = \"propName\";
var myObj = {
propName: \"Some Value\"
}
myObj[someProp]; // \"Some Value\"
", + "Here is one more:", + "
var myDog = \"Hunter\";
var dogs = {
Fido: \"Mutt\",\n Hunter: \"Doberman\",\n Snoopie: \"Beagle\"
}
var breed = dogs[myDog]; // \"Hunter\"
console.log(breed)// \"Doberman\"
", "Note that we do not use quotes around the variable name when using it to access the property because we are using the value of the variable, not the name", "

Instructions

", "Use the playerNumber variable to lookup player 16 in testObj using bracket notation." @@ -3240,7 +3242,7 @@ "var player = testObj; // Change this Line" ], "tail": [ - "" + "if(typeof player !== \"undefined\"){(function(v){return v;})(player);}" ], "solutions": [ "var testObj = {\n 12: \"Namath\",\n 16: \"Montana\",\n 19: \"Unitas\"\n};\nvar playerNumber = 16;\nvar player = testObj[playerNumber];"