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

Matthew Alesci
Matthew Alesci
7,465 Points

Quiz Challenge.. Help!

All of my code works absolutely fine but when I try to make my alerts pop up I want it to take form of a paragraph, strong text. Although when I put my code just like he has done it in the video, it continuously shows the p tag and strong tag along with my text. I don't want the tags to show i want it to enlarge my text. Help?

Matthew Alesci
Matthew Alesci
7,465 Points

here is my code

var score = 0;

var basketball = prompt("What team does Carmelo Anthony play for?");
if ( basketball.toUpperCase() === "KNICKS" ) {
  alert("Correct!");
  score += 1;
} else if ( basketball.toUpperCase() === "NEW YORK KNICKS") {
  alert("Correct!");
  score += 1;
} else {
  alert("Sorry, wrong answer.");
}
var teenWolf = prompt("Name the MTV show that is focused around teenage wolves.");
if ( teenWolf.toUpperCase() === "TEEN WOLF") {
  alert("Correct!");
  score += 1;
} else {
  alert("Sorry, wrong answer.");
}
var MVP = prompt("Who was the NBA's MVP of the 2014-15 season");
if ( MVP.toUpperCase() === "STEPHEN CURRY") {
  alert("Correct!");
  score += 1;
} else if ( MVP.toUpperCase() === "CURRY") {
  alert("Correct!");
  score += 1;
} else {
  alert("Sorry, wrong answer.");
}
var team = prompt("What team is that MVP on?");
if ( team.toUpperCase() === "GOLDEN STATE WARRIORS") {
  alert("Correct!");
  score += 1;
} else if ( team.toUpperCase() === "WARRIORS") {
  alert("Correct!");
  score += 1;  
} else {
  alert("Sorry, wrong answer.");
}
var age = parseInt(prompt("Can you guess my age?"));
if ( age === 20) {
  alert("Correct!");
  score += 1;  
} else {
  alert("Sorry, wrong answer.");
}


if( score === 5) {
  alert("<p><strong>Congrats, you scored " + score + " out of 5 questions and have recieved the Golden Crown</strong></p>");
}
if( score === 4 || score === 3) {
  alert("<p><strong>Congrats, you scored " + score + " out of 5 questions and have recieved the Silver Crown</strong></p>");
}
if( score === 2 || score === 1) {
  alert("<p><strong>Congrats, you scored " + score + " out of 5 questions and have recieved the Bronze Crown</strong></p>");
}
if( score === 0) {
  alert("<p><strong>You scored " + score + " out of 5 questions and have recieved no crown. Shame on you!!</strong></p>");
}

2 Answers

Jason Desiderio
Jason Desiderio
21,811 Points

Matthew Alesci - unfortunately, you can't use HTML tags in JavaScript alert boxes. It looks like they are using "document.write" in the video rather than "alert"