var 10 var var if Math abs b-a console log Math abs b-a else console l

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var N = 10;
var a = 9;
var b = 5;
if(Math.abs(b-a) < N/2){
console.log(Math.abs(b-a));
}
else{
console.log(Math.abs(N-b+a));
}