This Swift code contains one error – can you select the line that is incorrect?
Tip: You should mentally run the code from top to bottom, meaning that if line 3 says an integer should be returned and line 10 tries to return a string, line 10 is the wrong one.
func takeExercise(repeat: Int, type: String) -> String {
var returnValue: String = ""
for _ in 0 ..< repeat {
returnValue += "I'm doing a \(type)\n"
}
if repeat < 10 {
returnValue += "That was easy!"
} else if repeat < 30 {
returnValue += "That was challenging!"
} else {
returnValue += "Phew - I need a break!"
}
retrun returnValue
}
print(takeExercise(repeat: 23, type: "deadlift"))
Link copied to your pasteboard.