0% found this document useful (0 votes)
7 views3 pages

CodePrint

The document contains JavaScript code for a quiz application focused on NFL teams. It includes functions for starting the quiz, updating the score, displaying results, and resetting the game. The application randomly selects images and answers from a list of NFL teams, allowing users to interact and test their knowledge.

Uploaded by

corixify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

CodePrint

The document contains JavaScript code for a quiz application focused on NFL teams. It includes functions for starting the quiz, updating the score, displaying results, and resetting the game. The application randomly selects images and answers from a list of NFL teams, allowing users to interact and test their knowledge.

Uploaded by

corixify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

3/22/24, 8:31 AM bakerfranke.github.

io/codePrint/

var imageList = getColumn("NFL Teams", "Image");


var teamList = getColumn("NFL Teams", "Team");
var answerIndex;
var correctAnswer;
var buttonClicked;

var incorrectList = [];

var score = 0;
setScreen("homeScreen");
onEvent("startQuizButton", "click", function( ) {
setScreen("quizScreen");
setText("scoreLabel", "Score: 0" );
updateScreen();
updateScore();
});
onEvent("doneButton", "click", function(){
setScreen("resultScreen");
results();
});
onEvent("restartButton", "click", function( ) {
setScreen("homeScreen");
setText("scoreLabel", "Score: 0" );
score = 0;
reset();
});
onEvent("answer0", "click", function( ) {
buttonClicked = 0;
updateScore();
});
onEvent("answer1", "click", function( ) {
buttonClicked = 1;
updateScore();
});
onEvent("answer2", "click", function( ) {
buttonClicked = 2;
updateScore();
});
onEvent("answer3", "click", function( ) {
buttonClicked = 3;
updateScore();
});

function updateScreen() {
answerIndex = randomNumber(0, imageList.length - 1);
var tempList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
setImageURL("quizImage", imageList[answerIndex]);
removeItem(tempList, answerIndex);
for (var i = 0; i < 4; i++) {
var index = randomNumber(0, tempList.length - 1);
incorrectList[i] = tempList[index];
removeItem(tempList, index);
}

https://bakerfranke.github.io/codePrint/ 1/3
3/22/24, 8:31 AM bakerfranke.github.io/codePrint/
54
setText("answer0", teamList[incorrectList[0]]);
55
setText("answer1", teamList[incorrectList[1]]);
56
setText("answer2", teamList[incorrectList[2]]);
57
setText("answer3", teamList[incorrectList[3]]);
58
correctAnswer = randomNumber(0,3);
59
setText("answer" + correctAnswer, teamList[answerIndex]);
60
}
61
function updateScore() {
62
if (buttonClicked == correctAnswer) {
63
score = score + 1;
64
setText("scoreLabel", "Score: " + score);
65
updateScreen();
66
}
67
}
68
function reset() {
69
score = 0;
70
updateScreen();
71
}
72
function results() {
73
setText("resultText", "Your final score is: " + score + "\n" + "\n" + "Click the restart butto
74
}
75
// Image Credits:
76
//White background: https://i.pinimg.com/originals/f5/05/24/f50524ee5f161f437400aaf215c9e12f.jpg
77
// NFL Logo: https://upload.wikimedia.org/wikipedia/en/thumb/a/a2/National_Football_League_logo.
78
// Buffalo Bills: https://cdn.freebiesupply.com/images/large/2x/buffalo-bills-logo-transparent.p
79
// Miami Dolphins: https://cdn.freebiesupply.com/images/large/2x/miami-dolphins-logo-transparent
80
// New England Patriots: https://cdn.freebiesupply.com/images/large/2x/new-england-patriots-logo
81
// New York Jets: https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/New_York_Jets_logo.svg/12
82
// Baltimore Ravens: https://cdn.freebiesupply.com/images/large/2x/baltimore-ravens-logo-transpa
83
// Cincinnati Bengals: https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Cincinnati_Beng
84
// Cleveland Browns: https://cdn.freebiesupply.com/images/large/2x/cleveland-browns-logo-transpa
85
// Pittsburg Steelers: https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Pittsburgh_Stee
86
// Houston Texans: https://cdn.freebiesupply.com/images/large/2x/houston-texans-logo-transparent
87
// Indianapolis Colts: https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Indianapolis_Co
88
// Jacksonville Jaguars: https://cdn.freebiesupply.com/images/large/2x/jacksonville-jaguars-logo
89
// Tennessee Titans: https://cdn.freebiesupply.com/images/large/2x/tennessee-titans-logo-transpa
90
// Denver Broncos: https://cdn.freebiesupply.com/images/large/2x/denver-broncos-logo-transparent
91
// Kansas City Chiefs: https://cdn.freebiesupply.com/images/large/2x/kansas-city-chiefs-logo-tra
92
// Las Vegas Raiders: https://1000logos.net/wp-content/uploads/2023/02/Las-Vegas-Raiders-Logo.pn
93
// Los Angeles Chargers: https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Los_Angeles_C
94
// Dallas Cowboys: https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/Dallas_Cowboys.svg/
95
// New York Giants: https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/New_York_Giants_lo
96
// Philadelphia Eagles: https://upload.wikimedia.org/wikipedia/en/thumb/8/8e/Philadelphia_Eagles
97
// Washington Commanders: https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Washington_C
98
// Chicago Bears: https://cdn.freebiesupply.com/images/large/2x/chicago-bears-logo-transparent.p
99
// Detroit Lions: https://cdn.freebiesupply.com/images/large/2x/detroit-lions-logo-transparent.p
100
// Green Bay Packers: https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Green_Bay_Packer
101
// Minnesota Vikings: https://cdn.freebiesupply.com/images/large/2x/minnesota-vikings-logo-trans
102
// Atlanta Falcons: https://cdn.freebiesupply.com/images/large/2x/atlanta-falcons-logo-transpare
103
// Carolina Panthers: https://cdn.freebiesupply.com/images/large/2x/carolina-panthers-logo-trans
104
// New Orlean Saints: https://cdn.freebiesupply.com/images/large/2x/new-orleans-saints-logo-tran
105
// Tampa Bay Buccaneers: https://1000logos.net/wp-content/uploads/2021/04/Tampa-Bay-Buccaneers-l
106
// Arizona Cardinals: https://cdn.freebiesupply.com/images/large/2x/arizona-cardinals-logo-trans
107
// Los Angeles Rams: https://i1.wp.com/www.retroseasons.com/retroimages/LA-Rams-Primary-mark-202
108
// San Francisco 49ers: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/San_Francisco_
109
// Seattle Seahawks: https://cdn.freebiesupply.com/images/large/2x/seattle-seahawks-logo-transpa

https://bakerfranke.github.io/codePrint/ 2/3
3/22/24, 8:31 AM bakerfranke.github.io/codePrint/

PDF document made with CodePrint using Prism

https://bakerfranke.github.io/codePrint/ 3/3

You might also like