mardi 31 janvier 2017

Trying to make age guessing game in Javascript with counter function; has not worked hitherto

Below is my code thus far for an educational exercise requiring that I make a guessing game with multiple hints and a counter function that terminates after four turns. I've searched SO extensively and found no help. I've reviewed my textbook to no avail. This code is as best as I can do with my present knowledge (class has only been on for a week, so admittedly that is paltry). Any assistance would be greatly appreciated!

if (answerSix != myAge) {
            while (guesses <= 4) {
                if (answerSix > myAge)
                    {alert('Too old!')};
                    guesses++;
                else if (answerSix < myAge)
                    {alert('Too young!')};
                    guesses++;
                }
                else if (guesses >= 4) {
                    {alert('You have guessed too many times! Game over!')};
                    {break};
                }
                }
            }
        else if (answerSix === myAge) {
                {alert('Got it like the \'79 SuperSonics!')};
                {break}
            }
            else {alert('Answer is invalid!')}

Aucun commentaire:

Enregistrer un commentaire