will1858 / MI-449-js-conditionals

0 stars 0 forks source link

Project Feedback #1

Open will1858 opened 5 years ago

will1858 commented 5 years ago

Write a short choose-your-own adventure game in JavaScript

@egillespie Can you take a look at this? It's hosted here and meets the following criteria:

egillespie commented 5 years ago

Nice work on this project, @will1858! I really like how you can improve your odds by making certain choices and how you are using truthy conditions to simplify some of the game logic. 👍

Here are some ways I think your game can be improved. Can you try these out?

Use else if after checking if a value is null

In the places where you call window.prompt to collect a value, you are checking for null before using the value, but if I click Cancel on a prompt, I will still see an error and your game stops running:

image

This happens because after you show the alert that I chose an invalid option, the code continues to run the next if condition. For example:

  if (codeword === null) {
    window.alert('That is not an option')
  }
  if (codeword.toUpperCase().trim() === 'RUN') {

To avoid this, you can use an else if instead of an if for the second condition to ensure that it will only run when the value is not null.

Do you mind updating the spots in your code where this is happening to use an else if for the second condition so I'm unable to cause errors in your game?

Collect a number and use it

At least one number value is collected and used in a comparison (don't forget to convert it into a number first)

I don't see a number being collected in your code. Do you mind introducing this into your story somehow?


After you’ve made your changes and pushed them to GitHub and your hosted site, give it a once-over to make sure it looks right, then comment back here and I’ll take another look.

Thanks! 🚀

will1858 commented 5 years ago

completed

egillespie commented 5 years ago

Your changes rock, @will1858! Good work! 🎉 :shipit: