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 JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge Solution

Julian Martinez
Julian Martinez
3,094 Points

The code stops after I type ruby into the first prompt box

For some reason my code does not work from the second var onwards and I just can figure out why, i have done it exactly like in the video.

4 Answers

Julian Gutierrez
Julian Gutierrez
19,201 Points

A little more care when writing your code is all you need. There are several misspellings such as declaring var asnwer1 and then using answer1.

var correct = 0
var answer1 = prompt('Name a programming language that is also gem');
if (answer1.toUpperCase() === 'RUBY') {
  correct += 1;
}
var answer2 = prompt('Name a programming language that is also a snake');
if (answer2.toUpperCase() === 'PYTHON') {
  correct += 1;
}
var answer3 = prompt('What language do you use to style web pages?');
if (answer3.toUpperCase() === 'CSS') {
  correct += 1;
}
var answer4 = prompt('What langage do you use to build the structure of web pages?');
if (answer4.toUpperCase() === 'HTML') {
  correct += 1;
}
var answer5 = prompt('What language do you use to give ineractivity to a web page?');
if (answer5.toUpperCase() === 'JAVASCRIPT') {
  correct += 1;
}
document.write('You got ' + correct + ' out of 5 questions correct');
if (correct === 5) {
  document.write('You erned a gold crown');
} else if (correct >= 3) {
  document.write('You erned a silver crown');
} else if (correct >= 1) {
  document.write('You erned a bronce crown');
} else {
  document.write('No crown for you, You need to study.');
}
Julian Martinez
Julian Martinez
3,094 Points

ar correct = 0

var asnwer1 = prompt("Name a programming language that is also gem"); if (answer1.toUpperCase() === 'RUBY') { correct += 1; }

var asnwer2 = prompt('Name a programming language that is also a snake'); if (answer2.toUpperCase() === 'PYTHON') { correct += 1; }

var asnwer3 = prompt('What language do you use to style web pages?'); if (answer3.toUpperCase() === 'CSS') { correct += 1; }

var asnwer4 = prompt('What langage do you use to build the structure of web pages?'); if (answer4.toUpperCase() === 'HTML') { correct += 1; }

var asnwer5 = prompt('What language do you use to give ineractivity to a web page?'); if (answer5.toUpperCase() === 'JAVASCRIPT') { correct += 1; }

document.write("<p>You got " + correct + " out of 5 questions correct</p>");

if (correct === 5) { document.write('<p><strong>You erned a gold crown</strong></p>'); } else if (correct >= 3) { document.write('<p><strong>You erned a silver crown</strong></p>'); } else if (correct >= 1) { document.write('<p><strong>You erned a bronce crown</strong></p>'); } else { document.write('<p><strong>No crown for you, You need to study.</strong></p>'); }

Julian Martinez
Julian Martinez
3,094 Points

yes!!! yes!!! Thank you very very much Julian!!! it worked!!! you are completely right! I really need to be more careful with my codes!!!