Skip to content

Instantly share code, notes, and snippets.

@Magdalenaspace
Forked from TheMuellenator/optionals.swift
Created January 19, 2022 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Magdalenaspace/84d4964e156b20d9e962ab955e95587f to your computer and use it in GitHub Desktop.
Save Magdalenaspace/84d4964e156b20d9e962ab955e95587f to your computer and use it in GitHub Desktop.
iOS repl.it - Optionals Challenge Solution
//Don't change this
var studentsAndScores = ["Amy": Int(readLine()!)!, "James": Int(readLine()!)!, "Helen": Int(readLine()!)!]
func highestScore(scores: [String: Int]) {
//Write your code here.
let a = studentsAndScores["Amy"]!
let b = studentsAndScores["James"]!
let c = studentsAndScores["Helen"]!
var temp = 0
//If a is greater than b
if a > temp {
//And a is also greater than c
temp = a
}
if b > temp {
temp = b
}
if c > temp {
temp = c
}
print(temp)
}
//Don't change this
highestScore(scores: studentsAndScores)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment