Complete the code to create an array and add an element.
var numbers = [1, 2, 3] numbers.[1](4)
The append method adds an element to the end of an array in Swift.
Complete the code to copy an array and modify the copy without changing the original.
var original = [1, 2, 3] var copy = original copy.[1](4) print(original.count)
Appending to the copy does not change the original array because arrays are value types in Swift.
Complete the code to add "Cherry" to the fruits array.
var fruits = ["Apple", "Banana"] fruits.[1]("Cherry")
let) or using invalid methods like 'push'.To modify an array, it must be declared with var, not let which creates an immutable value. Use append to add an element to the end.
Fill both blanks to create a dictionary and add a new key-value pair.
var capitals = [1]<String, String>() capitals["France"] = [2]
Array instead of Dictionary for the first blank.Use Dictionary to create a dictionary and assign the value "Paris" to the key "France".
Fill all three blanks to create a set, add an element, and check if it contains a value.
var fruits = [1]<String>() fruits.[2]("Apple") let hasApple = fruits.[3]("Apple")
append which is for arrays, not sets.Use Set to create a set, insert to add an element, and contains to check if the set has a value.