Recursive Multiplication Given an JavaScript object list of books that each have a pages attribute to define the number of pages in the book, find the product of all the pages in the object list of...



Recursive Multiplication


Given an JavaScript object list of books that each have a
pages
attribute to define the number of pages in the book, find the
product of all the pages
in the object list of books using recursion (you must use recursion to solve this problem).


Keep in mind:



  • The input list object may be completely empty (ex. {})

  • Thenext
    attribute may not be defined


function getPageCount(list) {
// your code here
// returns an integer
}


Example test case:
Input:

{
"book":"A",
"pages":1,
"next":{
"book":"B",
"pages":2,
"next":{
"book":"C",
"pages":3,
"next": null
}
}
}


Output: 6
Reasoning: 1 * 2 * 3 pages



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here