I am trying to write a code that shows the last digit (in a set of 3) is the same. I could not understand why I got false for each set so, I decided to test -20%10 and I got -0 meanwhile 20%10 gives me the expected 0. What is this -0 about?
function last_digit( x, y, z){
if(x % 10 == y % 10 == z % 10 ){
return true;
}else {
return false;
}
}
console.log(last_digit(20, 30, 400));
console.log(last_digit(-20, 30, 400));
console.log(last_digit(20, -30, 400));
console.log(last_digit(20, 30, -400));