-
Notifications
You must be signed in to change notification settings - Fork 22.9k
4th set of JS active learning updates #40276
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
4th set of JS active learning updates #40276
Conversation
Preview URLs
(comment last updated: 2025-07-10 08:32:39) |
files/en-us/learn_web_development/core/scripting/test_your_skills/arrays/index.md
Outdated
Show resolved
Hide resolved
## Task 2 | ||
If you make a mistake, you can clear your work using the _Reset_ button in the MDN Playground. If you get really stuck, you can view the solution below the live output. | ||
|
||
<!-- Code shared across examples --> |
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.
I'm happy we can use this here 👍🏻
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.
Yeah, I love that we can do this. Unfortunately, the other articles didn't have so much scope for reuse.
// Don't edit the code below here! | ||
|
||
const section = document.querySelector("section"); | ||
|
||
const para1 = document.createElement("p"); | ||
para1.textContent = `Array: ${myArray}`; | ||
|
||
const para2 = document.createElement("p"); | ||
para2.textContent = `The length of the array is ${arrayLength}.`; | ||
|
||
const para3 = document.createElement("p"); | ||
para3.textContent = `The last item in the array is "${lastItem}".`; | ||
|
||
section.appendChild(para1); | ||
section.appendChild(para2); | ||
section.appendChild(para3); |
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.
Could make it a little more compact or even hidden?
// Don't edit the code below here! | |
const section = document.querySelector("section"); | |
const para1 = document.createElement("p"); | |
para1.textContent = `Array: ${myArray}`; | |
const para2 = document.createElement("p"); | |
para2.textContent = `The length of the array is ${arrayLength}.`; | |
const para3 = document.createElement("p"); | |
para3.textContent = `The last item in the array is "${lastItem}".`; | |
section.appendChild(para1); | |
section.appendChild(para2); | |
section.appendChild(para3); | |
``` | |
```js hidden live-sample___arrays-2 | |
// The following code checks if your edits work. | |
// Don't edit after this line! | |
const section = document.querySelector("section"); | |
const para1 = document.createElement("p"); | |
para1.textContent = `Array: ${myArray}`; | |
const para2 = document.createElement("p"); | |
para2.textContent = `The length of the array is ${arrayLength}.`; | |
const para3 = document.createElement("p"); | |
para3.textContent = `The last item in the array is "${lastItem}".`; | |
section.appendChild(para1); | |
section.appendChild(para2); | |
section.appendChild(para3); |
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.
Hey @bsmth! After reading your comment, I experimented with hiding various sections of code to see what the experience was like. I ended up not going for a solution like this, for a couple of reasons:
- When the code is loaded up in MDN Playground, it gets rid of line breaks at the start and end of the blocks, even if you set them to
-nolint
in the MDN page. As a result, you get comments right next to one another in a way I didn't want, which annoyed me. - When you jump over to the MDN Playground and are presented with code that you didn't know was there, it feels a bit jarring/surprising. I didn't feel like this would be a good experience, especially not for beginners.
To cut down on the size of these examples, I have done two things:
- Removed unnecessary blank lines, as you suggested.
- Truncated the shown "don't edit" code with ellipsis comments (
// ...
) inside the solution listings, keeping the other comments for context so the reader is less likely to get confused about where the solution should go.
Since this is a significant change, I'd like you to review this update to see if you think it works. Thanks!
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.
Super, thanks, Chris.
I ended up not going for a solution like this, for a couple of reasons:
Good, that all makes sense, tnx. Taking a look now
files/en-us/learn_web_development/core/scripting/test_your_skills/conditionals/index.md
Outdated
Show resolved
Hide resolved
files/en-us/learn_web_development/core/scripting/test_your_skills/conditionals/index.md
Outdated
Show resolved
Hide resolved
files/en-us/learn_web_development/core/scripting/test_your_skills/events/index.md
Outdated
Show resolved
Hide resolved
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.
Really glad we're refreshing these. General comment about format, and a question about hiding some of the logic checks in JS, but otherwise, looking great! Thank you 👏🏻
…lls/arrays/index.md Co-authored-by: Brian Smith <brian@smith.berlin>
…lls/conditionals/index.md Co-authored-by: Brian Smith <brian@smith.berlin>
…lls/conditionals/index.md Co-authored-by: Brian Smith <brian@smith.berlin>
…lls/events/index.md Co-authored-by: Brian Smith <brian@smith.berlin>
myArray.unshift("crocodiles"); | ||
|
||
// Don't edit the code below here! | ||
// ... |
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.
Yeah this looks good, tnx
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.
This looks really tidy now, nice work
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.
Super, thanks @bsmth. I'll follow the same pattern in future PRs.
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.
Looking great, Chris! 👏🏻
Description
As part of a larger project to make the challenges/reader exercises in MDN learn more consistent, this PR:
Motivation
Additional details
Related issues and pull requests