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

Adrian Rosario
seal-mask
.a{fill-rule:evenodd;}techdegree
Adrian Rosario
Front End Web Development Techdegree Student 13,532 Points

I was not able to make it work the same way he did on the video but this is what I did...

// Question and answers, if correct it will assign a value of 1

var question1 = prompt("Is the USA a contry? (Yes or No)"); 
var question2 = prompt("Are dogs better than cats? (Yes or No)");
var question3 = prompt("Is chicken delicioso? (Yes or No)");
var question4 = prompt("What is 10% of $2000?");
var question5 = prompt("Who is the best BF in the world?");

if (question1.toUpperCase() === 'YES') {
    question1 = 1;
} else {
    question1 = 0;
};

if (question2.toUpperCase() === 'YES') {
    question2 = 1;
} else {
    question2 = 0;
};

if (question3.toUpperCase() === 'YES') {
    question3 = 1;
} else {
    question3 = 0;
};

if (+question4.toUpperCase() === 200) {
    question4 = 1;
} else {
    question4 = 0;
};
if (question5.toUpperCase() === 'ADRIAN') {
    question5 = 1;
} else {
    question5 = 0;
};

var totalCorrect = question1 + question2 + question3 + question4 + question5; 


//Player Ranking 
let playerRank = "";
let fontColor = "";

if (totalCorrect === 5 ) {
     playerRank = "Gold";
     fontColor = "gold";

} else if (totalCorrect === 4){
     playerRank = "Silver";
     fontColor = "silver";

} else if (totalCorrect === 3){
     playerRank = "Bronze";
     fontColor = "#CD7F32";

} else if (totalCorrect === 2){
     playerRank = "Copper";
     fontColor = "light-brown";

} else {
     playerRank = "Bad";
     fontColor = 'black';

};

document.querySelector("main").innerHTML = `<h1> You got ${totalCorrect} correct answers. Your rank is <span style="color: ${fontColor}">${playerRank}</span>.`; ```