mdn/sprints

'JavaScript basics' issue

chimpchimpo21 opened this issue · 3 comments

Request type

  • Please close this issue, I accidentally submitted it without adding any details
  • New documentation
  • Correction or update

Details

This module originally instructs users to type these two lines at the top of our 'main.js' document:
const myHeading = document.querySelector('h1');
myHeading.textContent = 'Hello, world!';

When we get further into the tutorial ['Adding a personalized welcome message'] we are told to write the following two lines:
let myButton = document.querySelector('button');
let myHeading = document.querySelector('h1');

However, this seems to conflict with the 'const' from before. I asked a friend (experienced JS user) who told me to change the 'const' to a 'let' at the top of the document and only add the - let myButton = document.querySelector('button'); - at the bottom.

This fixed the issue. Before I asked him, the button would not do anything when I clicked it.

https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics

Hi @chimpchimpo21 !

The two parts you are citing are in conflict, agreed.

However, before the second one, you are asked to "Also delete your Hello world! JavaScript from the earlier exercise." — see bullet number 4 under the "Adding an image changer" heading.

However, I don't think this instruction is very obviously placed, so I'm going to move it and change it to make it clearer.

OK, I've updated the document — see mdn/content@122aa5a for the change diff.

I think this is better now, so I'm closing this issue, but feel free to chime in if you have more queries.