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

The Conditional Challenge - My Solution

A simple true/false JavaScript quiz

https://w.trhou.se/1bsf8zeei4

Brad Mason
Brad Mason
1,910 Points

the shortest version i could come up with

var q1 = prompt('What is the best programming language??');
var q2 = prompt('How many ears do i have??');
var q3 = prompt('What is my name?');
var q4 = prompt('Am i a dog??');
var q5 = prompt('Who am i??');
var score = 0;
if (q1.toLowerCase() === 'javascript'){
  score ++;
}
if (q2 === '2'){
  score ++;
}
if (q3.toLowerCase() === 'brad'){
  score ++;
}
if (q4.toLowerCase() === 'maybe'){
  score ++;
}
if (q5.toLowerCase() === 'petey pablo'){
  score ++;
}
if (score === 5) {
 alert("You earned a Gold medal!!"); 
} else if (score === 4 || score === 3){
 alert('You earned a silver medal');
} else if (score === 2 || score === 1){
 alert('You earned a bronze medal'); 
} else {
 alert('You didnt even try did you?'); 
}

2 Answers

Aldo Ramos
Aldo Ramos
2,678 Points

Nice, i have a question, how does the "++" work alongside the variable?

It increases the value by 1