True Or False Game
Part of the Introduction to SwiftUI section of Coddy's Swift journey. Lesson 50 of 50.
Challenge
HardBuild a true or false game over the questions array:
- while questions remain, show the current question's text (identifier
question) and two buttons,TrueandFalse. A tap adds one toscorewhen it matches the question'sanswer, then moves to the next question - after the last question, show
Score: 2/3(identifierresult) and aPlay againbutton that resets the score and starts over
Keep the current position in an index state starting at 0.
Try it yourself
import SwiftUI
@main
struct CoddyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}All lessons in Introduction to SwiftUI
Practice on your own: Swift playground