Learn Basic JavaScript by Building a Role Playing Game - Step 49

The Prompt for this say’s the following:

You need to wrap the text Store in double quotes. Because your string is already wrapped in double quotes, you’ll need to escape the quotes around Store. You can escape them with a backslash \ . Here is an example:

// The Example below:
const escapedString = “Naomi likes to play "Zelda" sometimes.”;
Wrap the text Store in double quotes within your text.innerText line. //

// This what I did. I did it in multiple ways & still came out wrong. please help me so I may move on Thank You my fellow coder. //

function goTown() {
Attempt 1: button1.innerText = "Go to \ "store\ “.”; ( Wrong )
Attempt 2: button1.innerText = "Go to \ "store\ ". ; ( Wrong )
Attempt 3: button1.innerText = "Go to \ "store\ "; ( Wrong )
Attempt 4: button1.innerText = "Go to \ “store”\ ; ( Wrong )
Attempt 5: button1.innerText = "Go to \ “store”\ "; ( Wrong )
}
& with that I give up

// Below Is the original //

function goTown() {
button1.innerText = “Go to store”;
button2.innerText = “Go to cave”;
button3.innerText = “Fight dragon”;
button1.onclick = goStore;
button2.onclick = goCave;
button3.onclick = fightDragon;
text.innerText = “You are in the town square. You see a sign that says Store.”;
}

I have updated your post to include the challenge so we can better assist you.
When asking questions on the forum, it is important to include this link.

Also, here is how to add code to the forum without having to use a bunch of > before each line of code.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Your issue with all of these attempts here is that you are targeting the wrong section

the line of code you need to change is this one. escape the double quotes around the word Store

hope that helps

Hello Wilkins. So I’ve tried & still nothing. I’ve wrapped Store like this

\"store\"; 

The same way how the word Zelda is supposed to be displayed in the example shown in the prompt which is this

const escapedString = “Naomi likes to play \"Zelda\" sometimes.”;

For mines it doesn’t go through & the semicolon doesn’t turn dark like it’s suppose to, at the end of each line of code. Instead it becomes the same color as the entire string before it. So I’m confused

Please post your full updated code.

You still need to close the string with a non-escaped quotation mark.

1 Like

As mentioned, you will need to post your full code so we can better assist you.

But looking at the bit you posted here tells me you might be still changing the wrong line of code

the word is not supposed to be all lowercase.

you need to make sure to update this line of code here

notice that the word is Store with a capital S not a lowercase one.

Also as mentioned, you need to also make sure the string is properly closed.

Hope that helps

Here is another example of escaping strings to help you better understand the concept.

const example = "Some example text with double quotes around \"text\"."

Prompt say’s the following below:

You need to wrap the text Store in double quotes. Because your string is already wrapped in double quotes, you’ll need to escape the quotes around Store . You can escape them with a backslash \ . Here is an example:

The Example Below:

const escapedString = "Naomi likes to play \"Zelda\" sometimes.";

Now I will show you all the attempts I did to get this correct & They still ALL came out wrong.

Attempt #1 below: I do it just like Zelda but it doesn’t pass & the semicolon becomes the same color as the string.

function goTown() {
  button1.innerText = "Go to \"store\";

Attempt #2 below: I add a period to see. The semicolon becomes dark but still doesn’t pass.

function goTown() {
  button1.innerText = "Go to \"store\".";

Attempt #3 below: I put the 2nd Double Quote inside to see. Semicolon is dark. Doesn’t pass.

function goTown() {
  button1.innerText = "Go to \"store"\;

Attempt #4 below. I realized Store in the prompt has a capital S. So I write it like these

function goTown() {
  button1.innerText = "Go to \"Store\";
function goTown() {
  button1.innerText = "Go to \"Store;

Moral of the story is I’ve done enough attempts to try & pass this step & nothing is working. It’s about to be a full day. I would just like to be told what it is just so I could move on from this but of course you may help me spot out the problem because I’m very confused & a bit annoyed

function goTown() {
  button1.innerText = "Go to store";
  button2.innerText = "Go to cave";
  button3.innerText = "Fight dragon";
  button1.onclick = goStore;
  button2.onclick = goCave;
  button3.onclick = fightDragon;
  text.innerText = "You are in the town square. You see a sign that says Store.";
}

This is the original code:

function goTown() {
  button1.innerText = "Go to store";
  button2.innerText = "Go to cave";
  button3.innerText = "Fight dragon";
  button1.onclick = goStore;
  button2.onclick = goCave;
  button3.onclick = fightDragon;
  text.innerText = "You are in the town square. You see a sign that says Store.";
}

You should only add the \" for the string on the line that starts with text.innerText.

Wrap the text Store in double quotes within your text.innerText line.

oh wow lol I just realized I was on the wrong line of code :joy: the whole time. Honestly my apologies to you guys. I totally forgot I had text.innerText As soon as I saw the first store word I was a man on a mission & forgot about everything else. Thank you though

1 Like

i still could’nt get it what is the correct code.

do you have the code that is correct i can’t solve this if you have show it

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.