Tell us what’s happening:
Hello. There is a problem with my code. Please help me.
const newLocation = {
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠',
};
locations.push(newLocation);
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const newLocation = {
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠',
};
locations.push(newLocation);
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.0.0.0
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 139
Dennis-code153:
const newLocation = {
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠',
};
Hi!
The instructions is asking you: In the locations array, add another object at the end. Set the name property to “lose”, set “button text” to an array with three “REPLAY?” strings, set “button functions” to an array with three restart variables, and set text to “You die. ”.
You didn’t need to create a new array. Reset the challenge step and add the above key/value pairs in an object within the existing locations array.
Always Read the instructions carefully.
hasanzaib1389:
Hi!
The instructions is asking you: In the locations array, add another object at the end. Set the name property to “lose”, set “button text” to an array with three “REPLAY?” strings, set “button functions” to an array with three restart variables, and set text to “You die. ”.
You didn’t need to create a new array. Reset the challenge step and add the above key/value pairs in an object within the existing locations array.
Always Read the instructions carefully.
After changing I have the next:
const locations = [
];
locations.push({
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠'
});
Dennis-code153:
const locations = [
];
That should be removed.
Dennis-code153:
locations.push({
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠'
});
That also not required locations.push(). Reset the challenge step and add an object {} in the challenge editor. Then add the required key/value pairs.
Example:
{
//Add required key/value pairs here
}
The last code is:
const locations = [
{
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠'
}
];
You have added an extra locations array. Just reset the challenge step and you see the line number 73 there. Where you need to add an object with that required key/value pairs given in the challenge instructions.
There is a Reset button below the challenge editor, use that button to reset the challenge to restore the original code back.
Dennis-code153:
const locations = [
{
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠'
}
];
I’ve done so and deleted th array. The result is:
{
name: 'lose',
'button text': ['REPLAY?', 'REPLAY?', 'REPLAY?'],
'button functions': [restart, restart, restart],
text: 'You die. ☠'
}
Dennis-code153:
'You die. ☠'
I realized that emoticon you added to the code, it’s causing error. Instead of that you need You die. ☠
1 Like
Thank you for helping me solve this challenge.
1 Like
system
Closed
May 12, 2025, 2:59am
12
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.