Post

Replies

Boosts

Views

Activity

Reply to Need help for lesson 14
Hy there, What do you think about this solution: var countYes = 0 var countNo = 0 for value in shouldInstallCoffeeVendingMachineVotes {     let countVotes = "\(value)"     if countVotes.hasPrefix("true") {         countYes += 1     } else { countNo += 1     } } if countYes countNo {     print("We have a winner.\nWe have count \(countYes) true votes and \(countNo) false votes.") } else if countYes countNo {     print("Sorry, but the vote didn't passed.\nWe have count \(countYes) true votes and \(countNo) false votes.") } else {     print("We have an equity, so we have to vote again.\nWe have count \(countYes) true votes and \(countNo) false votes.") }
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21