Question

create a javascript function named bbqFood that takes in an object and returns an array. The...

create a javascript function named bbqFood that takes in an object and returns an array. The input object will have strings naming party foods as the key and the numbers of people that each key will feed as its values. return an array containing all of the keys whose values are greater than 10, menaing it will feed more than 10 people.

example

bbqfood(['taco':15, 'hamburger':6,'pasta':42,'fruit':23}) must return ['taco','pasta','fruit']

0 0
Add a comment Improve this question Transcribed image text
Answer #1
function bbqfood(foods) {
    var lst = [];
    for (var key in foods) {
        if (foods.hasOwnProperty(key) && foods[key] > 10) {
            lst.push(key);
        }
    }
    return lst;
}

console.log(bbqfood({'taco': 15, 'hamburger': 6, 'pasta': 42, 'fruit': 23}));
Add a comment
Know the answer?
Add Answer to:
create a javascript function named bbqFood that takes in an object and returns an array. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT