var prices = [1.50, 10.00, 4.99, 2.30, 8.5]
let largePrices = prices.filter( { prices β Bool in
return prices > 3
})
print(largePrices)
print statement is this [10.0, 4.9900000000000002, 8.5]
why does it get that when thats not even in the array?
@lac_ekim The print
statement formats the arrayβs elements before printing them out in this case. If you want to get the exact value for each and every one of them, use a for in
loop instead:
for price in largePrices {
print(price)
}
Please let me know if you have any other questions or issues. Thank you! :]
1 Like
This topic was automatically closed after 166 days. New replies are no longer allowed.