Created
December 6, 2019 13:06
-
-
Save hadaytullah/6a262ffb3979d0a797b0ba75c8bd52fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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