What is Nostr?
js-nquiz /
npub1vvl…ud4v
2023-08-21 09:58:07

js-nquiz on Nostr: {"questionMarkdown":"We are in the mood for writing code. Using Bracket Notation, how ...

{"questionMarkdown":"We are in the mood for writing code. Using Bracket Notation, how do we access the correct property to get epic battle instrumental?\r\n \r\n var codeMusic = {\r\n \"reading code\": \"hip-hop jazz\",\r\n \"writing code\": \"epic battle instrumental\",\r\n \"debugging code\": \"mission impossible soundtrack\"\r\n };","explanationMarkdown":"The correct answer is \r\n\r\n codeMusic['writing code'];\r\n\r\nBracket Notation is awesome. There are many different uses for it and accessing objects is one great use. Similar to how Dot Notation uses a dot, Bracket Notation uses brackets. Here, we get our epic battle instrumental music by first using our brackets [], then our quotes '', and using the correct property name inside the quotes. Don't forget the semicolon (;)! Very important part of our code.\r\n\r\nNow, why are there quotes (\"doublequotes\", 'single quotes')? The use of the quotes (\"\") in the property name is important when there are spaces between words, such as \"writing code\". If our property name was just ***write*** then there would be no need for quotes in that property. However, when using Bracket Notation, you would still need quotes for the property. It would look like this:\r\n\r\n codeMusic['write'];\r\n\r\n Javascript does not discriminate between single and double quotes. Check out [This Great Video](https://www.youtube.com/watch?v=ASc0_m5bTeY) that further explains Dot and Bracket Notations.","answers":[{"isCorrect":true,"answerMarkdown":"codeMusic['writing code'];"},{"isCorrect":false,"answerMarkdown":"codeMusic['epic battle instrumental'];"},{"isCorrect":false,"answerMarkdown":"codeMusic[writing-code];"},{"isCorrect":false,"answerMarkdown":"codeMusic[\"writing code : epic battle instrumental\"]"}],"topics":["objects","es5"]}
Author Public Key
npub1vvlnd266fedzsvmj980hh4uhyh9jnwjd46v58u28kqggc9lp5h8sd3ud4v