Skip to content

Commit

Permalink
Change instruction no.4
Browse files Browse the repository at this point in the history
It was a bit confusing, it looked like it was supposed to go inside the ```setUserName()``` function.
  • Loading branch information
cartesian-plane authored Jan 26, 2024
1 parent ee05e49 commit fbc5c64
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ Next, let's change the page title to a personalized welcome message when the use

The `setUserName()` function contains a [`prompt()`](/en-US/docs/Web/API/Window/prompt) function, which displays a dialog box, similar to `alert()`. This `prompt()` function does more than `alert()`, asking the user to enter data, and storing it in a variable after the user clicks _OK._ In this case, we are asking the user to enter a name. Next, the code calls on an API `localStorage`, which allows us to store data in the browser and retrieve it later. We use localStorage's `setItem()` function to create and store a data item called `'name'`, setting its value to the `myName` variable which contains the user's entry for the name. Finally, we set the `textContent` of the heading to a string, plus the user's newly stored name.

4. Add the following condition block. We could call this initialization code, as it structures the app when it first loads.
4. Add the following condition block after the function declaration. We could call this initialization code, as it structures the app when it first loads.

```js
if (!localStorage.getItem("name")) {
Expand Down

0 comments on commit fbc5c64

Please sign in to comment.