One day, the host at a wedding decided to entertain the guests and set a rule: each guest who comes makes a toast, and all guests drink for the health of the newlyweds.
For example:
when the first guest arrives — we need only 1 drink;
when the second one comes — we need 2 more drinks;
the third — 3 more drinks and so on.
If there are 5 guests, then we need 15 drinks in total (1 + 2 + 3 + 4 + 5).
If 10, then 55 drinks (1 + 2 + 3 + ... + 10).
let sum = 0;
function getDrinks (numberOfGuests) {
for (let numberOfPortions = 1; numberOfPortions <= numberOfGuests; numberOfPortions++){
sum += numberOfPortions;
}
console.log (sum);
}
getDrinks ();