JSFiddle - React, Tailwind, and code Playground
JavaScript
x1 = 12.24;
x2 = 346.92;
z = Math.floor((Math.random() * 346) + 1);
z_ = z;
if (Math.abs (z - x1) < Math.abs (z - x2)){
z = x1;
}
else{
z = x2
}
alert(z_ + " is closer to : "+ z);