I am creating a Javascript algorithm to do the calculation similar to a tick meter, where you have the time for the flag 1 and the flag 2 .
function test(hora,bandeira1, bandeira2) {
if (hora >= bandeira1 && hora < bandeira2) {
console.log("calculou como bandeira 1");
} else {
console.log("calculou como bandeira 2");
}
}
// Retorna: "calculou como bandeira 2"
test(23,1,7);
If I perform a test passing test (23,8,1) the algorithm will not work correctly, it should point to flag 1, but it points to flag 2.
Could you help me make an algorithm where any combination I pass prevails in the normal order of a taximeter?