Complete the code to declare a constant in Swift.
let [1] = 10
var or func as names.In Swift, let declares a constant. Here, score is the name of the constant.
Complete the code to safely unwrap an optional using if-let.
if let value = optional[1] { print(value) }
! which forces unwrap and can cause crashes.The ? after optional means it might have a value. if let safely unwraps it.
Fix the error in the function declaration to follow Swift best practices.
func greet(name: String[1] String) { print("Hello, \(name)!") }
Function parameters are separated by commas , in Swift.
Fill both blanks to create a dictionary comprehension that filters keys with values greater than 5.
let filtered = dictionary.filter { $0.value [1] 5 }.[2] { $0.key: $0.value }filter twice instead of map.Use filter to select items where value is greater than 5, then map to create a dictionary from filtered pairs.
Fill all three blanks to create a safe optional binding with a guard statement.
guard let [1] = optionalValue [2] else { [3] }
if instead of else.else block.guard let unwraps optionalValue safely. The else block runs if unwrapping fails, and return exits the function early.