0

javascript console problem result is wrong with me but in tutorial its diffrent.

var heightJohn = 170; var heightMike = 195; var ageJohn = 36; var ageMike = 29; var scoreJohn = heightJohn + 5 * ageJohn; var scoreMike = heightMike + 5 * ageMike; if (scoreJohn > scoreMike) { console.log ('John wins the game with ' + scoreJohn + ' points!'); } else if (scoreMike > scoreJohn) { console.log('Mike wins the game with ' + scoreMike + ' points!'); } else if (scoreJohn === scoreMike) { console.log('There is a draw.'); } var heightMary = 158; var ageMary = 31; var scoreMary = heightMary + 5 * ageMary; if (scoreJohn > scoreMike && scoreJohn > scoreMary) { console.log('John wins the game with ' + scoreJohn + ' points!'); } else if (scoreMike > scoreJohn && scoreMike > scoreMary) { console.log('Mike wins the game with ' + scoreMike + ' points!'); } else if (scoreMary > scoreJohn && scoreMary > scoreMike) { console.log('Mary wins the game with ' + scoreMary + ' points!'); } else { console.log('It\'s a draw.'); } /* john wins the game with 350 points thats what i get . in tutorial its like this --------------------------------- john wins the game with 350 points scoreJohn 350 scoreMike 340 scoreMary 313 ------------------------------------------------------------- can someone help me with it

11th Dec 2017, 10:59 AM
Noman Noor Ali Shah
Noman Noor Ali Shah - avatar
2 Antworten
0
I can't understand your question clearly, but you can add this line to your code if you want to get the output you stated: console.log('scoreJohn\n'+scoreJohn+'\nscoreMike\n'+scoreMike+'\nscoreMary\n'+scoreMary); Have I answered your question?
13th Dec 2017, 9:18 AM
Hanz
Hanz - avatar
0
I'll check now
28th Dec 2017, 1:57 PM
Noman Noor Ali Shah
Noman Noor Ali Shah - avatar