Question: You are given an HTML document containing a two-dimensional table. Each row of this table consists of three cells containing information about a single

You are given an HTML document containing a two-dimensional table. Each row of this table consists of three cells containing information about a single loan of a book: name of the customer; date the book was borrowed (in ISO 8601 format); date the book was returned (this cell might be empty, which means that the book has not yet been returned). Rows containing the loans which are overdue should have a red background color. The loan is considered overdue if the book has been borrowed for strictly more than limit days. In other words, it was returned more than limit days after having been borrowed, or it was borrowed more than limit days ago and has not yet been returned. Your task is to write a function to test whether the table in the HTML document has been colored correctly according to the described schema; that is, whether only the rows containing overdue loans have a red background color. You should return the number of incorrectly marked rows. The table is created using table, tbody, tr and td tags. Each row marked in red will have a style property in a corresponding tr tag, in which the background-color CSS property is set to red; otherwise the background color of the row is not specified. Write a function: function solution (today, limit); that, given the current date in ISO 8601 format, today, and limit, the number of days after which a book is considered overdue, returns the number of incorrectly marked rows in the table provided in the HTML document. You may assume that the HTML document contains exactly one table. For example, given today = "2016-11-30", limit = 14 and a document which has the following table in its body: Donna 2016-10-01 Nansen 2016-11-05 2016-11-14 Peppe 2016-11-05 2016-11-14 J'Sira 2012-02-28 2012-03-14 Billie 2015-08-14 2015-10-09 Peyton 2015-08-14 2015-10-09 which, when displayed in a browser, produces the following output: Donna 2016-10-01 Nansen2016-11-052016-11-14 |||
Step by Step Solution
3.46 Rating (169 Votes )
There are 3 Steps involved in it
the following function returns the values of incorerctly colored rows function solutiontoday limit v... View full answer
Get step-by-step solutions from verified subject matter experts
