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

Sorry, your code does not pass. Don’t give up.

You should wrap the text Store in double quotes…
hello fellow coders am really stuck on this part kindly assist

what’s your code? what’s the link to the step?

let xp = 0;

let health = 100;

let gold = 50;

let currentWeapon = 0;

let fighting;

let monsterHealth;

let inventory = ["stick"];

const button1 = document.querySelector('#button1');

const button2 = document.querySelector("#button2");

const button3 = document.querySelector("#button3");

const text = document.querySelector("#text");

const xpText = document.querySelector("#xpText");

const healthText = document.querySelector("#healthText");

const goldText = document.querySelector("#goldText");

const monsterStats = document.querySelector("#monsterStats");

const monsterName = document.querySelector("#monsterName");

const monsterHealthText = document.querySelector("#monsterHealth");

// initialize buttons

button1.onclick = goStore;

button2.onclick = goCave;

button3.onclick = fightDragon;

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.'\"";

}

function goStore() {

button1.innerText = "Buy 10 health (10 gold)";

button2.innerText = "Buy weapon (30 gold)";

button3.innerText = "Go to town square";

button1.onclick = buyHealth;

button2.onclick = buyWeapon;

button3.onclick = goTown;

text.innerText = "You enter the store.";

}

function goCave() {

console.log("Going to cave.");

}

function fightDragon() {

console.log("Fighting dragon.");

}

function buyHealth() {

}

function buyWeapon() {

}

am stuck on step 49… and i really need to move ahead… i am supposed to wrap the word Store in double quotes within the text. innerText

you have both single and double quotes around Store, only double quotes. Remove the single quotes

text.innerText = "You are in the town square. You see a sign that says \"Store\"";

there it is, have made changes but nothing stills happens

The original code is

text.innerText = "You are in the town square. You see a sign that says Store.";

yours need to be identical but for the new quotes around “Store”. There is a difference between this and your code

1 Like

what I actually need is to wrap the text Store in double quotes using a backslash

The order is important when the escape character is used. The example code in this step is excellent.

Bear in mind what is required to define an entire string in the code - e.g. “string of characters”. It is imperative that the string have the quotes at its extremities, the absolute ends.

Concentrate specifically on the piece that is causing difficulty, the word Store. Note that the word is followed by a period or full stop.

You are very close. Do the above hints help?

Happy coding!

hellow… i have followed the example you have given above but it doesn’t work still… where exactly is the problem…
text.innerText = "You are in the town square. You see a sign that says \ ’ “Store. '"”;

You don’t need to put innerText, enough with text' and assignment operator and thenyour text`.

bro,there is actually a glitch or problem with coder itself TRY this copy this and paste it will work "Store"

where is the code to paste…

I have finished these courses and have no problem with the coder. Try to look at your code carefully, I’m sure there is something wrong. or you can try with a different browser. Try this and should work \"Store\"." . If still does not work please upload it to Github, so I can look at your code.

wow! i really love this it worked! Thanks so much

1 Like

You’re welcome reuben.

happy coding!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.