Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function christmasGift(input) {
- let index = 0;
- let command = input[index];
- let kids = 0;
- let adults = 0;
- let gift = 0;
- let pulover = 0;
- while (command !== 'Christmas') {
- currentYearsOld = Number(command);
- if (currentYearsOld <= 16) {
- kids++;
- } else if (currentYearsOld > 16) {
- adults++;
- }
- index++;
- command = input[index];
- }
- console.log(`Number of adults: ${adults}`);
- console.log(`Number of kids: ${kids}`);
- console.log(`Money for toys: ${kids * 5}`);
- console.log(`Money for sweaters: ${adults * 15}`);
- }
- christmasGift(['16','20','46','12','8','20','49','Christmas'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement