You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What information was incorrect, unhelpful, or incomplete?
When the user is asked to create the function setUserName he's presented with an example that concatenates the variable to a string:
function setUserName() {
let myName = prompt('Please enter your name.');
localStorage.setItem('name', myName);
myHeading.textContent = 'Mozilla is cool, ' + myName;
}
In the next example it's done in the same way:
if(!localStorage.getItem('name')) {
setUserName();
} else {
let storedName = localStorage.getItem('name');
myHeading.textContent = 'Mozilla is cool, ' + storedName;
}
Later he's asked to edit the setUserName function and the variable is now used inside the string:
function setUserName() {
let myName = prompt('Please enter your name.');
if(!myName) {
setUserName();
} else {
localStorage.setItem('name', myName);
myHeading.textContent = `Mozilla is cool, ${myName}`;
}
}
In my opinion this could be pretty confusing to someone getting started with JavaScript or programming in general. I think users would benefit from consistency or a very short explanation here.
MDN URL: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics
What information was incorrect, unhelpful, or incomplete?
When the user is asked to create the function
setUserName
he's presented with an example that concatenates the variable to a string:In the next example it's done in the same way:
Later he's asked to edit the
setUserName
function and the variable is now used inside the string:In my opinion this could be pretty confusing to someone getting started with JavaScript or programming in general. I think users would benefit from consistency or a very short explanation here.
Specific section or headline?
MDN Content page report details
en-us/learn/getting_started_with_the_web/javascript_basics
The text was updated successfully, but these errors were encountered: