Tell us what’s happening:
Hello everyone, kindly walk me through this challenge.
Your code so far
function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText = "You now have a"
}
}
The instruction is "You can insert variables into a string with the concatenation operator +. Update the You now have a new weapon. string to say You now have a and the name of the new weapon. Remember to end the sentence with a period.
Here is an example that creates the string Hello, our name is freeCodeCamp.:
const ourName = "freeCodeCamp";
const ourStr = "Hello, our name is " + ourName + "."
How do I update the text.innerText with the string?
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 91