Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics Making Decisions in Your Code with Conditional Statements The Conditional Challenge Solution

Nicolás Melgarejo
Nicolás Melgarejo
13,891 Points

MI solución // My solution

let correctAnswers = 0;

let rankPlayer = "";

const ranking = ["No crown", "Bronze", "Bronze", "Silver", "Silver", "Gold"]




alert("Iniciaremos con la racha de 5 preguntas. Presiona 'Aceptar' para iniciar")

const answer1 = prompt("1. Cuál es el apellido de Harry en la famosa saga de JK Rowling")
const answer2 = prompt("2. El primer Libro de Harry Potter trata sobre la Pierda...")
const answer3 = prompt("3. ¿Cuál es el nombre de la prisión donde estuvo el tio de Harry Potter?")
const answer4 = prompt("4. Cuántos libros conforman la saga original")
const answer5 = prompt("5. En J.K. Rowling, ¿qué significa la 'J' ?")




if (answer1.toUpperCase() === "POTTER") {
    correctAnswers += 1 ;
}

if (answer2.toUpperCase() === "FILOSOFAL") {
    correctAnswers += 1 ;
}

if (answer3.toUpperCase() === "AZKABAN") {
    correctAnswers += 1 ;
}

if (answer4.toString() === '7') {
    correctAnswers += 1 ;
}

if (answer5.toUpperCase() === "JOANNE") {
    correctAnswers += 1 ;
}

rankPlayer = ranking[correctAnswers];
let message = `<h1>Has conseguido ${rankPlayer}</h1> <p>Tu puntaje es de ${correctAnswers}</p>`
document.querySelector('main').innerHTML = message