So my code essentially just skips what I put in the if statement when I press the “Submit” button multiple times in the actual code. The first time I press it, it works fine, but from then on it immediately just skips the if statement.
This is my code on code.org
var player = getColumn("VCTLOCKIN", "PLAYER");
var playerimage = getColumn("VCTLOCKIN", "Picture");
var teamlogo = getColumn("VCTLOCKIN", "Team Logo");
var role = getColumn("VCTLOCKIN", "ROLE");
var leaguename = getColumn("VCTLOCKIN", "Leaue Name");
var id = getColumn("VCTLOCKIN", "id");
var amountcorrect = 0;
var amountwrong = 0;
onEvent("StartButton", "click", function( ) {
changeInfo();
setScreen("GameScreen");
});
function changeInfo() {
var randomIndex = randomNumber(0, id.length - 1);
setProperty("RandomInfo#1", "text", role[randomIndex]);
setProperty("RandomInfo#2", "text", leaguename[randomIndex]);
setProperty("RandomTeamLogo", "image", teamlogo[randomIndex]);
setProperty("PlayerImage", "image", playerimage[randomIndex]);
setProperty("CorrectScore", "text", amountcorrect);
setProperty("WrongScore", "text", amountwrong);
onEvent("SubmitButton", "click", function( ) {
evaluation();
});
function evaluation() {
if (getText("AnswerInput") == player[randomIndex]) {
amountcorrect++;
setScreen("Results");
setProperty("Results", "background-color", "green");
} else {
amountwrong++;
setScreen("Results");
setProperty("Results", "background-color", "red");
}
}
onEvent("NextButton1", "click", function( ) {
changeInfo();
setText("AnswerInput", "");
setScreen("GameScreen");
});
}