avaScript..

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...
icon
Related questions
Question

JavaScript.. 

The code module file, p3-module.js, will contain the following four functions.
validDenomination(coin):
• Returns true if the coin function parameter is a valid coin value of either 1, 5, 10, 25, 50, or 100
• Must use the array indexOf() method, and !== equality operator
• This function can be coded to be a single line of code
valueFromCoinObject(obj):
• Returns the calculated value of a single coin object from the obj function parameter
• Must use object deconstruction to create constant variables denom and count from the obj function parameter,
using default object values of 0 for denom and count
valueFromArray(arr):
• Iterates through an array of coin objects and returns the final calculated value of all coin objects
• Must use Array.reduce() method, and an arrow function with the Array.reduce() method
• Must call valueFromCoinObject()
• Extra credit: Handle scenario where the arr function parameter, rather than an array of coin objects, contains
another array of coin objects
coinCount(.coinage):
• This function is the only exported function from the code module
• Calls and returns the result of valueFromArray() function, which will be the value of all coin objects with the coinage
array function parameter
> Create and test each of the four functions:
• The functions are listed in the recommended order for development.
• The first two functions can be tested individually.
• The last two functions depend on other functions and should be coded last.
• Initially, code each function using whatever technique works, then refactor the functions to meet the specific
requirements.
• Test the code module using the following console.log() statements:
console.log("{}", coinCount({denom: 5, count: 3}):
console.log("{}s", coinCount{{denom: 5, count: 3},(denom: 10, count: 2});
const coins = [[denom: 25, count: 2),(denom: 1, count: 7}];:
console.log(.[{]", coinCount(.coins);
console.log("[{}]", coinCount(coins); / Extra credit
Transcribed Image Text:The code module file, p3-module.js, will contain the following four functions. validDenomination(coin): • Returns true if the coin function parameter is a valid coin value of either 1, 5, 10, 25, 50, or 100 • Must use the array indexOf() method, and !== equality operator • This function can be coded to be a single line of code valueFromCoinObject(obj): • Returns the calculated value of a single coin object from the obj function parameter • Must use object deconstruction to create constant variables denom and count from the obj function parameter, using default object values of 0 for denom and count valueFromArray(arr): • Iterates through an array of coin objects and returns the final calculated value of all coin objects • Must use Array.reduce() method, and an arrow function with the Array.reduce() method • Must call valueFromCoinObject() • Extra credit: Handle scenario where the arr function parameter, rather than an array of coin objects, contains another array of coin objects coinCount(.coinage): • This function is the only exported function from the code module • Calls and returns the result of valueFromArray() function, which will be the value of all coin objects with the coinage array function parameter > Create and test each of the four functions: • The functions are listed in the recommended order for development. • The first two functions can be tested individually. • The last two functions depend on other functions and should be coded last. • Initially, code each function using whatever technique works, then refactor the functions to meet the specific requirements. • Test the code module using the following console.log() statements: console.log("{}", coinCount({denom: 5, count: 3}): console.log("{}s", coinCount{{denom: 5, count: 3},(denom: 10, count: 2}); const coins = [[denom: 25, count: 2),(denom: 1, count: 7}];: console.log(.[{]", coinCount(.coins); console.log("[{}]", coinCount(coins); / Extra credit
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY