Merge pull request #15833 from Manish-Giri/fix/improve-existing-object-challenges

fix(challenges): Improve description in existing object challenges
pull/16073/merge
Dylan 2017-11-01 15:45:51 -05:00 committed by GitHub
commit 936223af47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 11 deletions

View File

@ -1089,8 +1089,8 @@
"In the <dfn>goodStr</dfn> above, you can use both quotes safely by using the backslash <code>\\</code> as an escape character.",
"<strong>Note</strong><br/>The backslash <code>\\</code> should not be be confused with the forward slash <code>/</code>. They do not do the same thing.",
"<hr>",
"Change the provided string to a string with single quotes at the beginning and end and no escape characters.",
"Right now, the <code>&#60;a&#62;</code> tag in the string uses double quotes everywhere. You will need to change the outer quotes to single quotes so you can remove the escape characters."
"Change the provided string to a string with single quotes at the beginning and end and no escape characters.",
"Right now, the <code>&#60;a&#62;</code> tag in the string uses double quotes everywhere. You will need to change the outer quotes to single quotes so you can remove the escape characters."
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
@ -2697,8 +2697,8 @@
],
"type": "waypoint",
"challengeType": 1,
"translations": {}
},
"translations": {}
},
{
"id": "56533eb9ac21ba0edf2244c3",
"title": "Assignment with a Returned Value",
@ -4229,9 +4229,12 @@
"description": [
"You may have heard the term <code>object</code> before.",
"Objects are similar to <code>arrays</code>, except that instead of using indexes to access and modify their data, you access the data in objects through what are called <code>properties</code>.",
"Here's a sample object:",
"<blockquote>var cat = {<br> \"name\": \"Whiskers\",<br> \"legs\": 4,<br> \"tails\": 1,<br> \"enemies\": [\"Water\", \"Dogs\"]<br>};</blockquote>",
"Objects are useful for storing data in a structured way, and can represent real world objects, like a cat.",
"Here's a sample cat object:",
"<blockquote>var cat = {<br> \"name\": \"Whiskers\",<br> \"legs\": 4,<br> \"tails\": 1,<br> \"enemies\": [\"Water\", \"Dogs\"]<br>};</blockquote>",
"In this example, all the properties are stored as strings, such as - <code>\"name\"</code>, <code>\"legs\"</code>, and <code>\"tails\"</code>. However, you can also use numbers as properties. You can even omit the quotes for single-word string properties, as follows:",
"<blockquote>var anotherObject = {<br> make: \"Ford\",<br> 5: \"five\",<br> \"model\": \"focus\"<br>};</blockquote>",
"However, if your object has any non-string properties, JavaScript will automatically typecast them as strings.",
"<hr>",
"Make an object that represents a dog called <code>myDog</code> which contains the properties <code>\"name\"</code> (a string), <code>\"legs\"</code>, <code>\"tails\"</code> and <code>\"friends\"</code>.",
"You can set these object properties to whatever values you want, as long <code>\"name\"</code> is a string, <code>\"legs\"</code> and <code>\"tails\"</code> are numbers, and <code>\"friends\"</code> is an array."
@ -4348,8 +4351,9 @@
"title": "Accessing Object Properties with Bracket Notation",
"description": [
"The second way to access the properties of an object is bracket notation (<code>[]</code>). If the property of the object you are trying to access has a space in its name, you will need to use bracket notation.",
"However, you can still use bracket notation on object properties without spaces.",
"Here is a sample of using bracket notation to read an object's property:",
"<blockquote>var myObj = {<br> \"Space Name\": \"Kirk\",<br> \"More Space\": \"Spock\"<br>};<br>myObj[\"Space Name\"]; // Kirk<br>myObj['More Space']; // Spock</blockquote>",
"<blockquote>var myObj = {<br> \"Space Name\": \"Kirk\",<br> \"More Space\": \"Spock\",<br> \"NoSpace\": \"USS Enterprise\"<br>};<br>myObj[\"Space Name\"]; // Kirk<br>myObj['More Space']; // Spock<br>myObj[\"NoSpace\"]; // USS Enterprise</blockquote>",
"Note that property names with spaces in them must be in quotes (single or double).",
"<hr>",
"Read the values of the properties <code>\"an entree\"</code> and <code>\"the drink\"</code> of <code>testObj</code> using bracket notation and assign them to <code>entreeValue</code> and <code>drinkValue</code> respectively."
@ -4401,11 +4405,11 @@
"id": "56533eb9ac21ba0edf2244c9",
"title": "Accessing Object Properties with Variables",
"description": [
"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.",
"Another use of bracket notation on objects is to access a property which is stored as the value of a variable. This can be very useful for iterating through an object's properties or when accessing a lookup table.",
"Here is an example of using a variable to access a property:",
"<blockquote>var someProp = \"propName\";<br>var myObj = {<br> propName: \"Some Value\"<br >};<br>myObj[someProp]; // \"Some Value\"</blockquote>",
"Here is one more:",
"<blockquote>var myDog = \"Hunter\";<br>var dogs = {<br> Fido: \"Mutt\",\n Hunter: \"Doberman\",\n Snoopie: \"Beagle\"<br >};<br>var breed = dogs[myDog];<br>console.log(breed);// \"Doberman\"</blockquote>",
"<blockquote>var dogs = {<br> Fido: \"Mutt\",\n Hunter: \"Doberman\",\n Snoopie: \"Beagle\"<br>};<br>var myDog = \"Hunter\";<br>var myBreed = dogs[myDog];<br>console.log(myBreed); // \"Doberman\"</blockquote>",
"Another way you can use this concept is when the property's name is collected dynamically during the program execution, as follows:",
"<blockquote>var someObj = {<br> propName: \"John\"<br>};<br>function propPrefix(str) {<br> var s = \"prop\";<br> return s + str;<br>}<br>var someProp = propPrefix(\"Name\"); // someProp now holds the value 'propName'<br>console.log(obj[someProp]); // \"John\"</blockquote>",
"Note that we do <em>not</em> use quotes around the variable name when using it to access the property because we are using the <em>value</em> of the variable, not the <em>name</em>.",
"<hr>",
"Use the <code>playerNumber</code> variable to look up player <code>16</code> in <code>testObj</code> using bracket notation. Then assign that name to the <code>player</code> variable."