Click here to Skip to main content
15,886,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The code is in swift, trying to connect the names that in the friends list that at the bottom. To the message connected to the top.

Swift
func invite(allGuests: [String]) {
    for guest in allGuests {
        invite(guest: guest)
        
            }
    print("Dear \(guest),")
    print("I'd love for you to come to my birthday party!")
    print("It's going to be this Saturday at my house.")
    print("I hope that you can make it!")
    print("Love, Brenna\n")
}

 let friends = ["Cathy", "Maddie", "Julia", "Sophia", "Asher"]
 invite(allGuests: friends)


What I have tried:

I try switching and turning guest that in the print("Dear \(guest)") to "allGuest". That didn't work
Posted
Updated 4-Oct-17 19:44pm
v2

1 solution

Put the print statements inside the loop instead of outside it...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900