I have a function that displays "correct" when the user puts in the right answer.
This is how I call it:
The text is not showing up. How can I fix this?
Code Block Swift func displayCorrectOrIncorrect() -> some View { Group { if correctAnswer == quiz.answer { VStack { Text("Correct") } } else { VStack { Text("Incorrect, correct answer is \(correctAnswer)") } } } }
This is how I call it:
Code Block SwiftUI Button(action: { self.displayCorrectOrIncorrect() self.updateUI() })
The text is not showing up. How can I fix this?
I figured out another way actually as well. I made a variable and set it to an empty string value so when it was correct I made the variable = "correct". I then inputed into a text box in my VStack.
Code Block SwiftUI var correctOrIncorrect: String = "" Text(correctOrIncorrect) if correctAnswer == quiz.answer { correctOrIncorrect = "Good Job!" } else { correctOrIncorrect = "Correct answer is \(correctAnswer)"