If you're seeing this message, it means we're having trouble loading external resources on our website.

Jeżeli jesteś za filtrem sieci web, prosimy, upewnij się, że domeny *.kastatic.org i *.kasandbox.org są odblokowane.

Główna zawartość

Iterating over lists with loops

Zadanie

A nutrition scientist is working on code to calculate the most magnesium-rich foods.
Their program processes a list of numbers representing milligrams of magnesium in servings of food. The goal of the program is to create a new list that contains only the numbers that represent at least 30% of the recommended daily intake of 360 milligrams.
mgAmounts ← [50, 230, 63, 98, 80, 120, 71, 158, 41]
bestAmounts ← []
mgPerDay ← 360
mgMin ← mgPerDay * 0.3
FOR EACH mgAmount IN mgAmounts
{
    IF (mgAmount ≥ mgMin)
    {
        <MISSING CODE>
    }
}
A line of code is missing, however.
What can replace <MISSING CODE> so that this program will work as expected?
👁️Note that there may be multiple answers to this question.
Zaznacz wszystkie odpowiedzi, które pasują:
🤔