Skip to content
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

added Solution to optional Challenge 2 #10

Open
wants to merge 1 commit into
base: main
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
28 changes: 28 additions & 0 deletions 4-loops/99-bottles/FiveLittleMonkeys.swift
Original file line number Diff line number Diff line change
@@ -19,3 +19,31 @@ print ("\(numMonkeys) little monkey jumping on the bed.")
print ("They fell off and bumped their head!")
print ("Mama called the doctor and the doctor said")
print ("'Put those monkeys straight to bed!'")


// Solution to optional challenge 2

/*
// numOfMonkeys represents number of monkeys on bed
var numOfMonkeys: Int = 5

// Lyrics will print and decrease from 5 to the last one
for numOfMonkeys in stride(from: 5, to: 0, by: -1) {

// "line[number]Lyric" represents the line of the lyric on a verse
let line1Lyric: String = "\n\(numOfMonkeys) little Monkeys jumping on the bed..."
let line2Lyric: String = "\nOne fell off and bumped her head..."
let line3Lyric: String = "\nMama called the doctor and the doctor said..."
let line4Lyric: String = "\n'Hello? No more Monkeys jumping on the bed!'"

// Print the lyric iteration
print("\(line1Lyric) \(line2Lyric)\(line3Lyric)\(line4Lyric)")
}

// Last lyric
var lastVerse: String = "\nNo little Monkeys jumping on the bed...\nThey fell asleep while laying their heads...\nDoctor called Mama and Mama said...\n'Hello? No more Monkeys jumping on the bed!'"

// Print the final lyrics
print("\(lastVerse)")

*/