Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$(document).ready(function () {
function sol(today,limit){
let incorrectStyle = 0;
$("tr").each(function (key, val) {
let $tds = $(this).find('td'),
$rowStyle = $(this).css('background-color'),
customerId = $tds.eq(0).text(),
issueDate = new Date($tds.eq(1).text()),
returnDate = $tds.eq(2).text?new Date($tds.eq(2).text()):new Date();
const singleDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
const borrowDays = Math.round(Math.abs((issueDate - returnDate) / singleDay));
console.log($rowStyle);
if(borrowDays > limit && !$rowStyle.includes('background-color')){
incorrectStyle++;
}else if (borrowDays <= limit && $rowStyle.includes('background-color')){
incorrectStyle++;
}
});
}
console.log(sol(new Date(), 14));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment