Complete the code to declare a function named greet.
func [1]() { print("Hello!") }
func.The function name should be greet as specified.
Complete the code to declare a function named add that takes two Int parameters.
func add(_ a: Int, _ b: Int) -> Int {
return a [1] b
}The function should add the two parameters, so the operator is +.
Fix the error in the function declaration to correctly return a String.
func welcomeMessage(name: String) -> [1] { return "Welcome, \(name)!" }
Int or Bool.The function returns a greeting message, which is a String.
Fill both blanks to declare a function that takes a Double and returns its square as Double.
func square(number: [1]) -> [2] { return number * number }
Int instead of Double.The parameter and return type are both Double because the function squares a Double number.
Fill all three blanks to declare a function that returns a dictionary with keys as uppercase strings and values as their lengths for words longer than 3 letters.
func wordLengths(words: [String]) -> [String: Int] {
return words.filter { $0.count [3] 3 }.reduce(into: [String: Int]()) { result, word in result[[1]] = [2] }
}The function creates a dictionary with uppercase words as keys and their lengths as values, filtering words longer than 3 letters.