Treehouse is Some Kind of Special

2 min read

\"Create\"

I am building all kinds of things! Learning Loops, Arrays, and Objects now that I finished the JavaScript Basics course in 5 days. I have 6 badges and looking to get more and more, as quickly as possible.

Look out for a podcast soon on Treehouse, tomorrow or later today.

Check out this Pen I made from a Treehouse challenge. Did it for my writer friends. In order not to annoy you with alerts, I chose JavaScript to be the default tab in the Pen. Click the result tab to play:

 

[codepen_embed height=\”268\” theme_id=\”0\” slug_hash=\”oXadEd\” default_tab=\”js\” user=\”twhite96\”]
// quiz begins, no answers correct
var correct = 0;

// ask questions

var answer1 = prompt("This character wound up in 12 of Ernest Hemingway's short stories.");
if (answer1.toUpperCase() === 'NICK ADAMS') {
correct += 1;
}
var answer2 = prompt("Who wrote Uylsses?");
if (answer2.toUpperCase() === 'JAMES JOYCE') {
correct += 1;
}
var answer3 = prompt("This author wrote their best work in a collection of stories called Cathedral.");
if (answer3.toUpperCase() === 'RAY CARVER' || answer3.toUpperCase === 'RAYMOND CARVER') {
correct += 1;
}
var answer4 = prompt("She wrote In the Cemetery Where Al Jolson is Buried.");
if (answer4.toUpperCase() === 'AMY HEMPEL') {
correct += 1;
}
var answer5 = prompt("This writer drowned themselves in the river after filling her pockets with rocks in 1941");
if (answer5.toUpperCase() === 'VIRGINIA WOOLF') {
correct += 1;
}

// outputs results
alert("You got " + correct + " out of 5 questions correct.");

// outputs rank
if (correct === 5) {
alert("You won a gold Pulitzer wrapped in diamonds!");
} else if (correct >= 3) {
alert("You won the MacArthur Fellowship. Not bad.");
} else if (correct >= 1) {
alert("You made the Amazon Best Seller list for some niche genre. Not bad. Not good either.")
} else {
alert("You are a flash fiction writer with no credits. Sucks to be you!");
}

See the Pen <a href=\’http://codepen.io/twhite96/pen/oXadEd/\’>Literary Quiz for Writers (WIP)</a> by Tiffany White (<a href=\’http://codepen.io/twhite96\’>@twhite96</a>) on <a href=\’http://codepen.io\’>CodePen</a>.
[/codepen_embed]

CC BY-SA 4.0 Treehouse is Some Kind of Special by Tiffany White is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.