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 trialNicolás Melgarejo
15,531 PointsMI 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