Skip to content

Update MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.s… #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,46 @@
/*: 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

// write your code her

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 constantPractice(){
let name = "Kegan"
print(name)
}



constantPractice()

/*: 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 greetGuest(name: String){
print("Hello, \(name). Welcome to Earth!")
}



var guest1 = "Greg"
greetGuest(name: "Charlie")
greetGuest(name: "Marvin")
greetGuest(name: guest1)

/*: 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

guest1 = "Tom"
greetGuest(name: guest1)



Expand All @@ -45,7 +59,13 @@
*/
// write your code here

func returnNumbers(){
var num = 10
print(num)
num = 25
print(num)
}



returnNumbers()
returnNumbers()
//: 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.