Can someone help me with this javascript story | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can someone help me with this javascript story

Right now I am trying to create a series of alerts and prompts that would allow a user to experience an interactive story. However, I am having an issue with the responsiveness of the prompts. Using the prompts I was planning to allow the user to insert the choice callForHelp, takeShortcut, or wait after the storyMiddle alert which would take them to the storyEnding alert but I can't seem to get this to work no matter what I try. Do you guys have any suggestions? Source: https://code.sololearn.com/W497jo4VTLrv/#js ---------------------------------------------------------------------------- var instructions = { "choices": "This is a short story in which you will be able to influence its ending through the choices you make...in order to make these choices all you need to do is follow the instructions in the prompts." }; var storyBeginning = { "start": "Your car breaks down at a road far from the nearest town and you are surrounded on both sides by thick forest and a severe blizzard is moving toward you.", }; var choice = { "choicesMiddle": "Do you want to call for help, take a shortcut, or wait for a car to pass? Enter callForHelp, takeShortcut, or wait. What will you do?" }; var storyMiddle = { "callForHelp": "You realize that you forgot your phone charger", "takeShortcut": "As you scan the surroundings you see that the nearest city skyline is located past a dense forest. You see this as your only option and you advance toward it", "wait": "You wait for a driver to come pass you by but nobody comes and as time passes your car continues to keep getting colder" }; var storyEnding = { "fallAsleep": "You fall asleep and never wake up again" }; alert( instructions.choices ); alert( storyBeginning.start ); prompt( choice.choicesMiddle ); if ( choice.choicesMiddle =="callForHelp"){ alert( storyMiddle.callForHelp ); } else { prompt( "please input callForHelp, takeShortcut, or wait" ); } if ( choice.choicesMiddle == "takeShortcut" ){ alert( storyMiddle.takeShortcut

7th Mar 2018, 5:24 PM
Marquis Patton
1 Answer
+ 1
Have you made sure that the spelling is correct? Like someone may put in CallForHelp but it’s supposed to beCallforhelp.
7th Mar 2018, 5:33 PM
Jax
Jax - avatar