2
I’m creating a Javascript algorithm to make the calculation similar to that of a taximeter, where you have the time of flag 1 and of 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 point to flag 2.
Could help me make an algorithm where any combination I pass prevails the normal order of a taximeter?
It does not work for all combinations.. if you test: test(23,8,0) will give as flag 2, while should be flag 1..
– Mateus Carvalho