Complete the code to declare a variable with a specific type in Swift.
var name: [1] = "Alice"
In Swift, you declare a variable's type explicitly using String for text values.
Complete the code to declare a constant integer in Swift.
let age: [1] = 30
Use Int to declare an integer type in Swift.
Fix the error in the code by specifying the correct type for the variable.
var isActive: [1] = trueThe type Bool is used for true/false values in Swift.
Fill both blanks to create a dictionary with String keys and Int values.
var scores: [[1]: [2]] = ["Math": 90, "Science": 85]
Dictionaries in Swift use square brackets with key and value types separated by a colon. Here, keys are String and values are Int.
Fill all three blanks to create a typed array and access its first element.
var fruits: [[1]] = ["Apple", "Banana", "Cherry"] let firstFruit: [2] = fruits[[3]]
The array fruits holds String values. The first element is accessed at index 0 and assigned to a variable of type String.