Your First iOS & SwiftUI App: An App from Scratch, Episode 26: Challenge: Calculate the Difference |

Try improving the algorithm to calculate the difference so it is written in fewer lines of code.

This is a companion discussion topic for the original entry at

Sorry, I’m feeling a little stupid here… Can someone explain to me what this does?

    func points(sliderValue: Int) -> Int {
        var difference: Int = - sliderValue
        if difference < 0 {
            difference *= -1