Skip to content

Instantly share code, notes, and snippets.

@hadaytullah
Created December 6, 2019 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadaytullah/6a262ffb3979d0a797b0ba75c8bd52fd to your computer and use it in GitHub Desktop.
Save hadaytullah/6a262ffb3979d0a797b0ba75c8bd52fd to your computer and use it in GitHub Desktop.
$(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