List Iteration with a Condition
In a content management system, a feature is needed to count the number of articles that are longer than 500 words. Given a list of article word counts, which of the following loops correctly implements this feature?
A
foreach wordCount in articleWordCounts { if (wordCount > 500) count++; }
B
for each wordCount > 500 in articleWordCounts { count++; }
C
for (wordCount > 500 in articleWordCounts) { count++; }
D
for each (wordCount in articleWordCounts) { if (wordCount > 500) count++; }
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | mahmoudjibrin08 | 1 | 2 | 0m 34s | 56 |
| #2 | gtsak31 | 1 | 1 | 1m 12s | 28 |
| #3 | 20231725 | 0 | 1 | 0m 00s | -10 |
| #4 | jasonvikathompson | 1 | 2 | 2m 02s | -32 |
| #5 | afeldman0610 | 0 | 1 | 0m 43s | -53 |
| #6 | tianbo.shen | 0 | 1 | 0m 55s | -65 |
| #7 | soniahalepota2005 | 1 | 2 | 2m 48s | -78 |
| #8 | rpatton | 1 | 2 | 4m 45s | -195 |
| #9 | bhavneet.singhal | 1 | 4 | 4m 47s | -217 |
Items per page:
10
1 – 9 of 9
APFIVE