Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- func countVowels(in string: String) -> Int {
- var numberOfVowels = 0
- for vowel in string.lowercased() {
- switch vowel {
- case "a", "e", "i", "o", "u":
- numberOfVowels += 1
- //print(numberOfVowels)
- default:
- break
- }
- }
- //print(numberOfVowels)
- return numberOfVowels
- }
- countVowels(in: "The lazy sheep jumped over the moon.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement