Instruct ur Notes Help O IDE Settings Challenge: Should we order this candy? We want to know whether to order a particular candy. We should make an order if the total number in stock ( instock ) is less than the weekly average sold ( weeklyAverage ). Create a function called shouldweOrderThisCandy that takes in: • the inventory array • aspecific type of candy (string) The function should find the candy in the array that matches the name passed in. When that candy is found, return true if the number inStock is less than the weeklyAverage. Otherwise, return false. If the array doesn't have any candy with that name, return false Example input and output shouldweOrderThisCandy(inventory, "Twizzlers"); //-> true shouldweOrder ThisCandy (inventory, "Sour Patch Kids"); //-> true shouldweOrderThisCandy(inventory, "Milk Duds"); //-> false shouldweOrderThisCandy(inventory, "Now and Laters"); //-> false shouldweOrderThisCandy(inventory, "Broccoli Bits"); //-> false Sample inventory array This is a sample of the data that will be used in all of the challenges. let inventory = [ { candy: "Twizzlers", inStock: 180, weeklyAverage: 200 }, ( candy: "Sour Patch Kids", instock: 90, weeklyAverage: 100 }, { candy: "Milk Duds", instock: 300, weeklyAverage: 170 }. ( candy: "Now and Laters", instock: 15e, weeklyAverage: 40 ) Time: 769ms Passed: 0 Failed: 7 Exit Code: 7 Test Results:
Instruct ur Notes Help O IDE Settings Challenge: Should we order this candy? We want to know whether to order a particular candy. We should make an order if the total number in stock ( instock ) is less than the weekly average sold ( weeklyAverage ). Create a function called shouldweOrderThisCandy that takes in: • the inventory array • aspecific type of candy (string) The function should find the candy in the array that matches the name passed in. When that candy is found, return true if the number inStock is less than the weeklyAverage. Otherwise, return false. If the array doesn't have any candy with that name, return false Example input and output shouldweOrderThisCandy(inventory, "Twizzlers"); //-> true shouldweOrder ThisCandy (inventory, "Sour Patch Kids"); //-> true shouldweOrderThisCandy(inventory, "Milk Duds"); //-> false shouldweOrderThisCandy(inventory, "Now and Laters"); //-> false shouldweOrderThisCandy(inventory, "Broccoli Bits"); //-> false Sample inventory array This is a sample of the data that will be used in all of the challenges. let inventory = [ { candy: "Twizzlers", inStock: 180, weeklyAverage: 200 }, ( candy: "Sour Patch Kids", instock: 90, weeklyAverage: 100 }, { candy: "Milk Duds", instock: 300, weeklyAverage: 170 }. ( candy: "Now and Laters", instock: 15e, weeklyAverage: 40 ) Time: 769ms Passed: 0 Failed: 7 Exit Code: 7 Test Results:
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
this is JavaScript programming. please provide step by step code.
Expert Solution
Step 1
We need to to provide Javascript code for given scenario
Algorithm:
1. Defined function shouldWeOrderThisCandy(..) with pass inventory and candy type as argument
2. find if the input candy is in the inventory array loop though inventory
3. return true if inStock is less than the weekly average sold (weeklyAverage)
4. if not return false.
5. return false indicate that candy type is not in the inventory array.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY