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 trialThomas Wayne
Front End Web Development Techdegree Student 328 Pointsguil's quiz app is very had for me so i make my own quiz app
guil is very smart but his quiz app is veryx difficult for me so i make my own quiz app guil's quiz app only record of the scor the player mades but he doesnt look at the lossing points so i make my own if anyone also facing that issue then look at mine this is a lot simpler
let rank = 0; let ruby= prompt("what is a programming langauage which is also a gem ?"); let python = prompt("what is aprogramming language which is also a snake ?"); let css = prompt("what is a programming langauge to style web pages ?"); let html = prompt("what is a programming langauge to build web pages ?"); let javascript = prompt("what is a programming language to add ineractivity to web pages ?"); let correctGuess; let gold; let silver; let bronze; let nocrown;
if(ruby==="ruby"){ rank += 1; }else if(ruby !== "ruby"){ rank = 0; }
if(python==="python"){ rank += 1; }else if(python !== "python"){ rank = rank; }
if(css==="css"){ rank += 1; }else if(css !== "css"){ rank = rank; }
if(html==="html"){ rank += 1; }else if(html !== html){ rank = rank; }
if(javascript==="javascript"){ rank += 1; }else if(javascript !== "javascript"){ rank = rank; }
if(rank==0){ nocrown = "Nocrown"; }else if(rank==1 || rank==2){ bronze = "Bronze"; }else if( rank == 3 || rank == 4){ silver = "Silver"; }else if( rank == 5 ){ gold = "Gold" }
// 3. Select the <main> HTML element
let main = document.querySelector('main');
main.innerHTML=
<p>Your ${rank} answers are correct. That's why you won ${nocrown||bronze||silver||gold}</p>
;
1 Answer
Steven Parker
231,236 PointsYou can still simplify this even more, for example:
if (python === "python") {
rank += 1;
//} else if (python !== "python") {
// rank = rank;
}
The lines shown commented out can be omitted entirely since "rank = rank
" doesn't change anything.
But you mentioned keeping track of points lost, so you might want to do something like this:
if (python === "python") {
rank += 1;
} else { // another "if" not needed
lost += 1; // keep count of missed questions
}
And when posting code to the forum, use Markdown formatting to preserve the appearance and optionally add syntax coloring (as shown here).
Thomas Wayne
Front End Web Development Techdegree Student 328 PointsThomas Wayne
Front End Web Development Techdegree Student 328 Pointshey steven did you encouter any error while opening any page on mozilla developer network
Steven Parker
231,236 PointsSteven Parker
231,236 PointsI didn't use it while composing this answer, but I do use MDN frequently and have had no problems with it.