From 41de01e881724d22961d4d6be42f6a1fb9f4e59e Mon Sep 17 00:00:00 2001 From: Acidic Date: Sun, 16 Dec 2018 13:09:48 -0500 Subject: [PATCH] Complete problems --- .../main.xcplaygroundpage/Contents.swift | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index c1f926f..49b4fc0 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -13,9 +13,10 @@ /*: question1 ### 1. Create a function that will take in a continent and the number of countries in that continent. It should print the following sentence "____ is a continent which contains ___ countries". */ -// write your code here - - +func someFunction (continent: String, numberOfCountries: String) { + print("\(continent) is a continent which contains \(numberOfCountries) countries.") +} +someFunction(continent: "America", numberOfCountries: "2") /*: question2 @@ -25,7 +26,7 @@ func greeting(name: String, greeting: String) { print("\(greeting), \(name)!") } -greeting(name: "Danny", "Hello") +greeting(name: "Danny", greeting: "Hello") @@ -33,8 +34,8 @@ greeting(name: "Danny", "Hello") /*: question3 ### 3. This function doesn't work, either. Can you fix the function (_not_ the call) so that it works? */ -func daysInMonth(month: String, days: String) { - print("There are \(days) in \(month)") +func daysInMonth(month: String, days: Int) { + print("There are \(days) in \(month).") } daysInMonth(month: "November", days: 30) @@ -45,9 +46,10 @@ daysInMonth(month: "November", days: 30) /*: question4 ### 4. So far, you have created functions that take two arguments. Can you create (and call) one that takes three? Try to create a function that three parameters: a beverage, the number of bottles of that beverage, and a place you can keep those bottles. Print the sentence "____ bottles of ____ on the ____ wall." */ -// write your code here - - +func someNewFunc(beverage: String, bottles: Int, place: String) { + print("\(bottles) bottles of \(beverage) on the \(place) wall.") +} +someNewFunc(beverage: "Fanta", bottles: 19, place: "Kitchen") //: Click [here](https://github.com/learn-co-curriculum/swift-funcMultipleArg-lab/blob/solution/MyPlayground.playground/Pages/solution.xcplaygroundpage/Contents.swift) to see the solution.