Copy link to clipboard
Copied
Hi everyone,
I have a multiple choice quiz designed for a client. I have an array that works thruout the questions, that if the user answers incorrectly, it stores the question number in the array. When the user reaches the end of the quiz, I dont want this array to always display at the end, since the user could have all the asnwers correct (which means the array should be empty). I am trying to make an if else statement that will display a different message if the array is empty... but nothing I have tried works... any ideas? below is my code.
I tried this one:
if (questionsArray == null)
{
questionsWrong.text ="All questions are correct!";
}else
{
questionsWrong.text = "You missed question(s): " + questionsArray.toString();
}
and i also tried this one:
if ( questionsArray.toString == "")
{
questionsWrong.text ="All questions are correct!";
}else
{
questionsWrong.text = "You missed question(s): " + questionsArray.toString();
}
Thanks!
Rafa.
check to see if your array's length is zero.
Copy link to clipboard
Copied
check to see if your array's length is zero.
Copy link to clipboard
Copied
That did the trick!
Thanks kglad!
code:
if ( questionsArray.length == 0)
{
mytextField.text ="All questions are correct!";
}else
{
mytextField.text = "You missed question(s): " + questionsArray.toString();
}
Rafa.
Copy link to clipboard
Copied
you're welcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more