Junior — Senior
Determine the program output – option 12
livecode
Task condition
In this task, you need to analyze the behavior of the addScore function and predict what number will be output to the console. Pay attention to how the closure captures the variable score and how its value changes during the execution of the function.
import UIKit
func addScore(_ point: Int) -> Int {
var score = 11
let calculate = { $0 + score }
score = calculate(point)
return calculate(score)
}
print(addScore(10))