Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function asd(input) {
- let index = 0;
- let command = input[index];
- let kids = 0;
- let adults = 0;
- let toyMoney = 0;
- let sweeatersMoney = 0;
- while (command !== "Christmas") {
- let age = Number(input[index]);
- index++;
- if (age <= 16) {
- kids += 1;
- toyMoney += 5;
- } else {
- adults += 1;
- sweeatersMoney += 15;
- }
- command = input[index];
- }
- console.log(`Number of adults: ${adults}`);
- console.log(`Number of kids: ${kids}`);
- console.log(`Money for toys: ${toyMoney}`);
- console.log(`Money for sweaters: ${sweeatersMoney}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement