New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(challenges): Improve description in existing object challenges #15833
fix(challenges): Improve description in existing object challenges #15833
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Manish-Giri good work; let me know what you think of these suggestions.
@@ -4180,6 +4180,9 @@ | |||
"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.", | |||
"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 to their corresponding string types.", |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@@ -4349,11 +4353,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 lists of the object properties or for doing the lookup.", |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
"<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 breed = dogs[myDog];<br>console.log(breed); // \"Doberman\"</blockquote>", |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
"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 breed = dogs[myDog];<br>console.log(breed); // \"Doberman\"</blockquote>", | ||
"Bracket notation is also useful when you have to access a property whose name is collected dynamically during the program execution, as follows:", |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@dhcodes on it... |
@Manish-Giri Thanks for helping improve these. Have you had a chance to look at @dhcodes's suggestions yet? We're excited to merge this. |
18480ab
to
d8eb2b8
Compare
@Manish-Giri updated the pull request. |
@dhcodes @QuincyLarson Done! |
QA'ing now. |
"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." |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for sounding fickle, but it still doesn't flow right. I think if we rearrange some things and change a few words, it will be perfect.
@@ -4184,6 +4184,9 @@ | |||
"Here's a sample object:", |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@Manish-Giri ping! |
d8eb2b8
to
a6d031a
Compare
@raisedadead updated the pull request. |
@dhcodes I have gone ahead and made the changes as you recommended. Can you please give this a merge after a look. Thanks. |
LGTM @raisedadead 👍 🎉 |
Thanks @Manish-Giri 💯 |
@Manish-Giri Thanks for improving this! |
Pre-Submission Checklist
staging
branch of freeCodeCamp.fix/
,feature/
, ortranslate/
(e.g.fix/signin-issue
)npm test
. Usegit commit --amend
to amend any fixes.Type of Change
Checklist:
Description
Collecting suggestions from #12141, this PR improves the description in three of the introductory lessons on objects. The set of modified descriptions is intended to lay the platform for a new challenge which would require the camper to have knowledge on accessing object properties with bracket notation, among other things.
Eventually, this will make solving the "Profile Lookup" challenge much easier (see #15616).
Closes #12141