Complete the code to declare a constant in Swift.
let number = [1]In Swift, let declares a constant, so you assign a value like 10 to it.
Complete the code to declare a variable in Swift.
var name = [1]Variables declared with var can change. Here, name is set to the string "Alice".
Fix the error in the code by choosing the correct keyword to allow changing the value.
[1] score = 5 score = 10
The error occurs because let creates a constant that cannot be reassigned. Use var to declare a variable that can be changed.
Choose the keyword that allows mutating the array by appending an element.
[1] scores = [85, 90] scores.append(95)
let makes the array a constant and prevents mutating methods like append. Use var to declare mutable arrays.
Choose the keyword that allows the function to modify the counter.
[1] counter = 0 func incrementCounter() { counter += 1 } incrementCounter() print(counter)
To modify counter from within the function, declare it with var. Constants declared with let cannot be changed.