From 8d4fcf86fd123dd671687bf4fcd0f6ef865bcc79 Mon Sep 17 00:00:00 2001 From: tandrewfield Date: Sun, 28 Oct 2018 20:13:22 -0500 Subject: [PATCH] Complete Probs --- .DS_Store | Bin 0 -> 6148 bytes .../main.xcplaygroundpage/Contents.swift | 33 ++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..390c8296714564749b7d8ae3d3807846b5610b1c GIT binary patch literal 6148 zcmeHKF;2r!41K?JC<38wF#eeVsW_3lud{8JZ?SWMIolxC!Ur4BUZ%=Wi=& z6&T8Z5ZIFaejMA$e_x7Y0Ab#iGhhl}LKPex(|jUwUvwZN^Nfih*SNzI)_6dTb`b53 z-^hTR-8pV}ZnxNA_x!dfafN2+-K=MeRb4f@oy)hwD^zt+lkK#p&OpzAd>{W(;qD^8Fq@Aj$p$_uqOwbP(pq>>&G09kQCiI z1J1xc14nu}mHvPI_58n|}1 dt@whPh5jfDVlwO$>7n?KK&HWsGw`Dfd;lyTMXdk; literal 0 HcmV?d00001 diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index 09e428b..3bfd4fe 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -11,15 +11,23 @@ /*: question1 ### 1. Write a function called `helloWorld()` that prints "Hello, world!" to the console. Then call it to see your string printed to the playground console. */ -// write your code here +func helloWorld (){ + print("Hello, world!") + +} +helloWorld() /*: question2 ### 2. Write your own function in which you declare a constant inside the function's body and then print that constant to the console. Call this function to see your string printed to the playground console. */ -// write your code here +func assignment (){ + let name = "Andy" + print (name) +} +assignment() @@ -27,7 +35,12 @@ /*: question3 ### 3. Write a function that takes a person's name as an argument and prints a greeting to the console. Call it several times with different arguments. What do you think you'll see in the console? */ -// write your code here +func whasSup (name:String){ + print ("Whassup, \(name)?") +} + +whasSup(name:"Andy") +whasSup(name:"BigDog") @@ -35,7 +48,9 @@ /*: question4 ### 4. Now call the function you wrote in Question 3 using a variable or constant instead of a string literal. What do you expect to see in the console? Try passing in a _variable_ you declared (using `var`) as an argument. Then change that variable's value and call your function again. What do you see in the console? */ -// write your code here +var colonel = "Joe" +whasSup (name:colonel) + @@ -43,9 +58,13 @@ /*: question5 ### 5. Write your own function in which you declare a _variable_ (of any type) inside the function's body. Print out this variable to the console from within your function. After you print the variable once, assign a new value to this variable on the next line. Print it again (after the line on which you assign it to a new value). Call your function several times. What do you expect to see printed to the playground's console each time you call this function? */ -// write your code here - - +func hellohi (){ + var date = 2 + print ("today is the \(date)st of the month.") + + print ("today is the \(date)st of the month.") +} +hellohi() //: Click [here](https://github.com/learn-co-curriculum/swift-functionLab-lab/blob/solution/MyPlayground.playground/Pages/solution.xcplaygroundpage/Contents.swift) for a link to the solution.