You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functioncountLargerThanTen(numbers){letcountSoFar=0;for(letnumberofnumbers){if(number>10){countSoFar=countSoFar+1;}}returncountSoFar;}letpile=[1,15,-10,3,15,88];letcountAbove10=countLargerThanTen(pile);console.log(`There are #{countAbove10} numbers larger than 10 in the list.`);
Python
defcount_larger_than_ten(numbers)count_so_far=0fornumberinnumbers:
ifnumber>10 :
count_so_far=count_so_far+1returncount_so_farpile=[1,15,-10,3,15,88]count_above_10=count_larger_than_ten(pile)print(f'There are {count_above_10} numbers larger than 10 in the list.')
Ruby
defcount_larger_than_ten(numbers)count_so_far=0numbers.eachdo|number|if(number>10)count_so_far=count_so_far+1endendreturncount_so_farendpile=[1,15,-10,3,15,88]count_above_10=count_larger_than_ten(pile)puts("There are #{count_above_10} numbers larger than 10 in the list.")