MCPcopy Create free account
hub / github.com/codemistic/Web-Development / showRandom

Function showRandom

disney-character-game/index.js:118–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116var randomChar;
117
118function showRandom() {
119 randomResultBox.style.display = "flex";
120
121 var randNum = Math.floor(Math.random() * 4 + 1);
122
123 var charName = document.getElementById("char-name");
124 var charImg = document.getElementById("char-img");
125 var charMovie = document.getElementById("char-movie");
126 var charFriend = document.getElementById("char-friend");
127 var charNemesis = document.getElementById("char-nemesis");
128 var charQuote = document.getElementById("char-quote");
129
130 if (randNum == 1) {
131 randomChar = "Din Djarin";
132 charName.innerHTML = "<h3>Name: Din Djarin</h3>";
133 charImg.src = "./images/din_djarin.png";
134 charMovie.innerHTML = "Movie: The Mandalorian (Series)";
135 charFriend.innerHTML = "Friend: Grogu";
136 charNemesis.innerHTML = "Nemesis: Moff Gideon";
137 charQuote.innerHTML =
138 'Quote: "I\'m a Mandalorian. Weapons are part of my religion."';
139 } else if (randNum == 2) {
140 randomChar = "Han Solo";
141 charName.innerHTML = "<h3>Name: Han Solo</h3>";
142 charImg.src = "./images/han_solo.png";
143 charMovie.innerHTML = "Movie: Solo: A Star Wars Story";
144 charFriend.innerHTML = "Friend: Chewbacca";
145 charNemesis.innerHTML = "Nemesis: Jabba the Hutt";
146 charQuote.innerHTML = 'Quote: "Never tell me the odds!"';
147 } else if (randNum == 3) {
148 randomChar = "Luke Skywalker";
149 charName.innerHTML = "<h3>Name: Luke Skywalker</h3>";
150 charImg.src = "./images/luke_skywalker.png";
151 charMovie.innerHTML = "Movie: Star Wars: Episode IV - A New Hope";
152 charFriend.innerHTML = "Friend: R2-D2";
153 charNemesis.innerHTML = "Nemesis: Darth Vader";
154 charQuote.innerHTML = 'Quote: "I am a Jedi, like my father before me."';
155 } else if (randNum == 4) {
156 randomChar = "Rey";
157 charName.innerHTML = "<h3>Name: Rey</h3>";
158 charImg.src = "./images/rey.png";
159 charMovie.innerHTML = "Movie: Star Wars: Epise VII - The Force Awakens";
160 charFriend.innerHTML = "Friend: BB-8";
161 charNemesis.innerHTML = "Nemesis: Kylo Ren";
162 charQuote.innerHTML =
163 'Quote: "Let\'s see how you could hold up against the power of the Force."';
164 } else {
165 randomChar = "Din Djarin";
166 randomResult.innerHTML = "Whoops! Something went wrong.";
167 }
168
169 compareBtn.style.display = "block";
170}
171
172// Compare input and random characters
173var compareResult = document.getElementById("compare-result");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected