exercise help swift 4

0

Good evening I am learning swift 4 and I was caught with this exercise that I can not solve and I have tried hard to solve it and I can not find the solution. help please

    
asked by S.Figueroa 26.09.2018 в 01:39
source

1 answer

0

I do not see anything wrong with your code.

import Foundation

let ChangeVotes: [Bool] = [true,true,true,false,false,true]
let numTrue = ChangeVotes.filter({$0 == true}).count
let numFalse = ChangeVotes.filter({$0 == false}).count

print("Cantidad true: \(numTrue)")
print("Cantidad false: \(numFalse)")

Print:

Cantidad true: 4
Cantidad false: 2

You can check this by saving this code in a file "file.swift" and running it on your terminal with swift archivo.swift or link

    
answered by 26.09.2018 / 05:42
source