Skip to content

Commit fd7b607

Browse files
authored
Update FizzBuzz.swift
Added Docstrings for easier understanding for beginners.
1 parent e592ed6 commit fd7b607

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Fizz Buzz/FizzBuzz.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// Last checked with Xcode Version 11.4.1 (11E503a)
22

3+
4+
/**
5+
* This function takes in an integer numberOfTurns as an input and prints out the numbers from 1 to numberOfTurns with the following modification:
6+
* - If the number is divisible by 3, it prints "Fizz" instead of the number
7+
* - If the number is divisible by 5, it prints "Buzz" instead of the number
8+
* - If the number is divisible by both 3 and 5, it prints "Fizz Buzz" instead of the number
9+
* - If the numberOfTurns is less than 1, it will print "Number of turns must be >= 1"
10+
*
11+
* - parameter numberOfTurns: the number of turns for the fizzbuzz game
12+
*/
13+
14+
315
func fizzBuzz(_ numberOfTurns: Int) {
416
guard numberOfTurns >= 1 else {
517
print("Number of turns must be >= 1")
@@ -18,4 +30,4 @@ func fizzBuzz(_ numberOfTurns: Int) {
1830
print("Fizz Buzz")
1931
}
2032
}
21-
}
33+
}

0 commit comments

Comments
 (0)