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

Tell us what’s happening:

Hello. There is something wrong with my code because it doesn’t pass. I want to realise what is a failure but unfortunately I can’t. Please help me.

export const locations = [
    {
        name: 'town square',
        'button text': ['Go to forest', 'Go to beach'],
        'button functions': [goForest, goBeach],
        text: 'You are in the town square. You see a path to the forest and another to the beach.'
    },
    
    {
        name: 'easter egg',
        'button text': ['2', '8', 'Go to town square?'],
        'button functions': [pickTwo, pickEight, goTown],
        text: 'You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!'
    }
];
import { locations } from './main.js';
console.log(locations);

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region


export const locations = [
    {
        name: 'town square',
        'button text': ['Go to forest', 'Go to beach'],
        'button functions': [goForest, goBeach],
        text: 'You are in the town square. You see a path to the forest and another to the beach.'
    },
    
    {
        name: 'easter egg',
        'button text': ['2', '8', 'Go to town square?'],
        'button functions': [pickTwo, pickEight, goTown],
        text: 'You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!'
    }
];
import { locations } from './main.js';
console.log(locations);

// 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 161

Hi there!

Don’t code that the instructions not asked

You should strictly follow the instructions, when doing the curriculum challenges.

Why are you using export here were is it going?

I tried to figure out my mistake on the developer console on my own and corrected the code myself several times, hence the result.

export const locations = [
    {
        name: 'town square',
        'button text': ['Go to forest', 'Go to beach'],
        'button functions': [goForest, goBeach],
        text: 'You are in the town square. You see a path to the forest and another to the beach.'
    },
    {}, 
    {}, 
    {}, 
    {}, 
    {}, 
    {}, 
    {
        name: 'easter egg',
        'button text': ['2', '8', 'Go to town square?'],
        'button functions': [pickTwo, pickEight, goTown],
        text: 'You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!'
    }
];

Now I’m trying to correct the code accoding the instruction.

The export is still there.

And Why are you added that extra object?

The the developer console gives some information and I follow it. According to the next information:

// running tests 1. Your

locations

array should have 8 values. 2. Your eighth

locations

value should be an object. 3. Your eighth

locations

value should have a

name

property with the value

"easter egg"

. 4. Your eighth

locations

value should have a

"button text"

array with the strings

"2"

,

"8"

, and

"Go to town square?"

. 5. Your eighth

locations

value should have a

"button functions"

an array with the variables

pickTwo

,

pickEight

, and

goTown

. 6. Your eighth

locations

value should have a

text

property with the value

"You find a secret game. Pick a number above. Ten numbers will be randomly chosen between 0 and 10. If the number you choose matches one of the random numbers, you win!"

. // tests completed // console output [ReferenceError: locations is not defined] [ReferenceError: locations is not defined] [ReferenceError: locations is not defined] [ReferenceError: locations is not defined] [ReferenceError: locations is not defined] [ReferenceError: locations is not defined]> Blockquote

That it. Your all required things

1 Like

Thank you very much for helping me separate the wheat grains from the chaff, otherwise I’m completely confused with the developer console, what should I take and what not.

1 Like

The console error is confusing you, because you added unnecessary things to your code. Reset the challenge step and strictly follow the instructions.

1 Like

Thank you for your explanations. They are very useful for me.

1 Like