This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Crystal Collector HW</title> | |
<link rel="stylesheet" type="text/css" href="assets/css/crystal.css"> | |
<link rel="stylesheet" type="text/css" href="crystal.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var globalCount = 0; | |
var RED = 0; | |
var PURPLE = 0; | |
var GREEN = 0; | |
var CLEAR = 0; | |
// ADINA: Why start WINS and LOSSES at 1? | |
var WINS = 1; | |
var LOSSES = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ADINA: This structure works but a constructor object would help you avoid repeating code. It would look something like this: | |
// var questions = []; | |
// function question(question, answers, correctAnswer) { | |
// this.question = question; | |
// this.answers = answers; | |
// this.correctAnswer = correctAnswer; | |
// questions.push(this); | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ADINA: This structure works but a constructor object would help you avoid repeating code. It would look something like this: | |
// | |
// // var questions = []; | |
// // function question(question, answers, correctAnswer) { | |
// // this.question = question; | |
// // this.answers = answers; | |
// // this.correctAnswer = correctAnswer; | |
// // questions.push(this); | |
// // } | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ADINA: Using an array for storing questions/answers but a constructor object would help you avoid repeating code. It would look something like this: | |
// var questions = []; | |
// function question(question, answers, correctAnswer) { | |
// this.question = question; | |
// this.answers = answers; | |
// this.correctAnswer = correctAnswer; | |
// questions.push(this); | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ADINA: Using an array for storing questions/answers but a constructor object would help you avoid repeating code. It would look something like this: | |
// | |
// var questions = []; | |
// function question(question, answers, correctAnswer) { | |
// this.question = question; | |
// this.answers = answers; | |
// this.correctAnswer = correctAnswer; | |
// questions.push(this); | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ADINA: This structure works but a constructor object would help you avoid repeating code. It would look something like this: | |
// var questions = []; | |
// function question(question, answers, correctAnswer) { | |
// this.question = question; | |
// this.answers = answers; | |
// this.correctAnswer = correctAnswer; | |
// questions.push(this); | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ADINA: What you did definitely works, but if you wanted to dynamically generate the input elements with javascript, this is how you would do it: | |
// var questions = [{ | |
// question: "What was the first full length CGI movie?", | |
// answers: ["A Bug's Life", "Monsters Inc.", "Toy Story", "The Lion King"], | |
// correctAnswer: "Toy Story" | |
// }, { | |
// question: "Which of these is NOT a name of one of the Spice Girls?", | |
// answers: ["Sporty Spice", "Fred Spice", "Scary Spice", "Posh Spice"], | |
// correctAnswer: "Fred Spice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ADINA: What you did definitely works, but if you wanted to dynamically generate the input elements with javascript, this is how you would do it: | |
// var questions = [{ | |
// question: "What was the first full length CGI movie?", | |
// answers: ["A Bug's Life", "Monsters Inc.", "Toy Story", "The Lion King"], | |
// correctAnswer: "Toy Story" | |
// }, { | |
// question: "Which of these is NOT a name of one of the Spice Girls?", | |
// answers: ["Sporty Spice", "Fred Spice", "Scary Spice", "Posh Spice"], | |
// correctAnswer: "Fred Spice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
//Declare topics | |
var topics = ["Spongebob", "Patrick", "Rick and Morty", "Peter Griffin", "Stewie Griffin", "Quagmire"]; | |
//Make initial buttons | |
for (i=0; i<topics.length; i++) { | |
makeButton(topics[i]); | |
} | |
//Make form for new button |