Comparing numbers and making a calculation
Given your conditions, there's no way around the if-else statements. You have to enforce the conditions somehow.

Instead of if-else, another option is a switch statement, but the outcome is essentially the same:

switch (true) {
    case Math.round(e.gamma) === 0:
        value = 0;
        break;
    case e.gamma &lt; -2:
        value = -2;
        break;
    case e.gamma &gt; 2:
        value = 2;
        break;
    default:
        value = 99;
}