Menu
Coddy logo textTech

True Or False Game

Part of the Introduction to SwiftUI section of Coddy's Swift journey. Lesson 50 of 50.

challenge icon

Challenge

Hard

Build a true or false game over the questions array:

  • while questions remain, show the current question's text (identifier question) and two buttons, True and False. A tap adds one to score when it matches the question's answer, then moves to the next question
  • after the last question, show Score: 2/3 (identifier result) and a Play again button 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