Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function zad2(input){
- let adults = 0, kids = 0, toysPrice = 0, sweatersPrice = 0;
- for(let i = 0; i < input.length; i++){
- if(input[i] == 'Christmas'){
- break;
- }
- if(!isNaN(input[i])){
- if(input[i] <= 16){
- kids++;
- }else{
- adults++;
- }
- }
- }
- toysPrice = kids*5;
- sweatersPrice = adults*15;
- console.log(`Number of adults: ${adults}`);
- console.log(`Number of kids: ${kids}`);
- console.log(`Money for toys: ${toysPrice}`);
- console.log(`Money for sweaters: ${sweatersPrice}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement