Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Choose Your Own Adventure Game - JavaScript

I'm stuck do not know how to continue, trying to make a text base choose your adventure game in js.

const game = { intro: { msg: 'Welcome to Tom and Jerry adventures!', img: 'https://via.placeholder.com/100x100', action: [ { text:'start', goto: 'start' } ] }, start: { msg:'Tom was walking to the kitchen suddenly he saw jerry eating cheese from the fridge what do you do?', img: 'https://via.placeholder.com/100x100', action: [ { text:'keep watching him eat the cheese', goto: 'keepWatch' }, { text:'chase him', goto:'chaseHim' }, { text: 'ignore it', goto: 'ignoreIt' } ] }, keepWatch: { msg:'(Keep Watching him) you kept watching him and your owners notice you were being lazy they hit you and tell you to chase after him, but jerry has already made it to his hole', img: 'https://via.placeholder.com/100x100', msg: "you make it to jerry's hole what do you do now?", action: [ { text:'set traps', goto: 'setTraps' }, { text:'play the waiting game', goto: 'wait' }, { text:'become friends with jerry', goto: 'friendship' } ] }, chaseHim: { msg:'you chase after and get hit by a pan jerry makes it to his hole', img: 'https://via.placeholder.com/100x100', msg: "you make it to jerry's hole what do you do now?", action: [ { text:'set traps', goto: 'setTraps' }, { text:'play the waiting game', goto: 'wait' }, { text:'become friends with jerry', goto: 'friendship' } ] }, ignoreIt: { msg:'you chose to ignore it and go back to sleep', msg: 'your owners catch you sleeping and almost trade you for another cat but you ask them for another chance, they say goto his hole', img: 'https://via.placeholder.com/100x100', msg: "you make it to jerry's hole what do you do know?", action: [ { text:'set traps', goto: 'setTraps' }, { text:'play the waiting game', goto: 'wait' }, { text:'become friends with jerry', goto: 'friendship' } ] }, setTraps: { msg:'what kinda of traps would you like to set?', img: 'https://via.placeholder.com/100x100', action: [ { text:'bait him with cheese', goto: 'bait' }, { text: 'hire a lady mouse', goto: 'ladyMouse' }, { text:'call the cat gang', goto: 'catGang' } ] }, bait: { msg: 'you baited jerry with cheese and he fell for your trap', img: 'https://via.placeholder.com/100x100', goto: 'YOU WIN' }, ladyMouse:{ msg:'you called a lady mouse and she fell in love with jerry now you have to worry about to mouses', img: 'https://via.placeholder.com/100x100' }, catGang:{ msg:'they sqaud came through but the owners found out and now they are lving inside and you have to find another place', img: 'https://via.placeholder.com/100x100' }, wait: { msg:"Playing the waiting game you decide to wait it out for jerry but he never comes out and you fall asleep, your owners catch you sleeping again", img: 'https://via.placeholder.com/100x100' }, friendship: { msg:'Become friends with jerry you try to become friends with jerry and tricks you gets you kicked out the house', img:'https://via.placeholder.com/100x100' } };

1 Answer

const game = {
    intro: {
        msg: 'Welcome to Tom and Jerry adventures!',
        img: 'https://via.placeholder.com/100x100',
        action: [
            {
                text:'start',
                goto: 'start'
            }
        ]
    },
    start: {
        msg:'Tom was walking to the kitchen suddenly he saw jerry eating cheese from the fridge what do you do?',
        img: 'https://via.placeholder.com/100x100',
        action: [
            {
                text:'keep watching him eat the cheese',
                goto: 'keepWatch'
            },
            {
                text:'chase him',
                goto:'chaseHim'
            },
            {
                text: 'ignore it',
                goto: 'ignoreIt'
            }
        ]
    },
    keepWatch: {
        msg:'(Keep Watching him) you kept watching him and your owners notice you were being lazy they hit you and tell you to chase after him, but jerry has already made it to his hole',
        img: 'https://via.placeholder.com/100x100',
        msg: "you make it to jerry's hole what do you do now?",
        action: [
            {
                text:'set traps',
                goto: 'setTraps'
            },
            {
                text:'play the waiting game',
                goto: 'wait'
            },
            {
                text:'become friends with jerry',
                goto: 'friendship'
            }
        ]
    },
    chaseHim: {
        msg:'you chase after and get hit by a pan jerry makes it to his hole',
        img: 'https://via.placeholder.com/100x100',
        msg: "you make it to jerry's hole what do you do now?",
        action: [
            {
                text:'set traps',
                goto: 'setTraps'
            },
            {
                text:'play the waiting game',
                goto: 'wait'
            },
            {
                text:'become friends with jerry',
                goto: 'friendship'
            }
        ]
    },
    ignoreIt: {
        msg:'you chose to ignore it and go back to sleep',
        msg: 'your owners catch you sleeping and almost trade you for another cat but you ask them for another chance, they say goto his hole',
        img: 'https://via.placeholder.com/100x100',
        msg: "you make it to jerry's hole what do you do know?",
        action: [
            {
                text:'set traps',
                goto: 'setTraps'
            },
            {
                text:'play the waiting game',
                goto: 'wait'
            },
            {
                text:'become friends with jerry',
                goto: 'friendship'
            }
        ]
    },
    setTraps: {
        msg:'what kinda of traps would you like to set?',
        img: 'https://via.placeholder.com/100x100',
        action: [
            {
                text:'bait him with cheese',
                goto: 'bait'
            },
            {
                text: 'hire a lady mouse',
                goto: 'ladyMouse'
            },
            {
                text:'call the cat gang',
                goto: 'catGang'
            }
        ]
    },
    bait: {
        msg: 'you baited jerry with cheese and he fell for your trap',
        img: 'https://via.placeholder.com/100x100',
        goto: 'YOU WIN'
    },
    ladyMouse:{
        msg:'you called a lady mouse and she fell in love with jerry now you have to worry about to mouses',
        img: 'https://via.placeholder.com/100x100'
    },
    catGang:{
        msg:'they sqaud came through but the owners found out and now they are lving inside and you have to find another place',
        img: 'https://via.placeholder.com/100x100'
    },
    wait: {
        msg:"Playing the waiting game you decide to wait it out for jerry but he never comes out and you fall asleep, your owners catch you sleeping again",
        img: 'https://via.placeholder.com/100x100'
    },
    friendship: {
        msg:'Become friends with jerry you try to become friends with jerry and tricks you gets you kicked out the house',
        img:'https://via.placeholder.com/100x100'
    }
};