//This are the variables that contain the important information/data for this app
var countryList = getColumn("Countries and Territories", "Country Name");
var flagList = getColumn("Countries and Territories", "Flag");
var index=0;
var countryGuess;
randomize();
//If you have made a guess, this will state if you guess was right or wrong
onEvent("guessButton", "click", function( ) {
countryTrueFalseFunction();
});
//This function declared if the guess that was made it true or false
function countryTrueFalseFunction() {
countryGuess = getText("guessText");
if (countryList[index]===countryGuess) {
setText("trueorFalse","True");
} else {
setText("trueorFalse","False");
}
}
//If the button is pressed, it will switch the flags to another country
onEvent("randomButton", "click", function( ) {
randomize();
});
//This will randomize the country flags that will be shown on the app
function randomize() {
//Cheesy way to fit requirement
for(var i = 0; i < randomNumber(0, flagList.length-1); i++) {
if(index == flagList.length) {
index = 0;
} else {
index++;
}
}
setProperty("countryFlag", "image", flagList[index]);
console.log(flagList[index]);
}