samedi 27 mars 2021

(JS) If statement calculate lowest variable

I wish to return the lowest value of the 4 variables. These values change all the time and i wish to display the lowest value. My issue; I keep getting [null] as result. I have checked the variables itself one by one, the all have values in them so the problem probably is in my if statement only i cant find out where. I appreciate any and all help ;)

Code:

var FL = $prop('GarySwallowDataPlugin.Leaderboard.Position01.Telemetry.TyresWearFR');
var FR = $prop('GarySwallowDataPlugin.Leaderboard.Position01.Telemetry.TyresWearFR');
var RL = $prop('GarySwallowDataPlugin.Leaderboard.Position01.Telemetry.TyresWearRL');
var RR = $prop('GarySwallowDataPlugin.Leaderboard.Position01.Telemetry.TyresWearRR');

{
   if (FL < FR && FL < RL && FL < RR){var returnValue = 100 - FL + '%';}
   else if (FR < FL && FR < RL && FR < RR){var returnValue = 100 - FR + '%';}
   else if (RL < FR && RL < FL & RL < RR){var returnValue = 100 - RL + '%';}
   else if (RR < FR && RR < RL && RR < FL){var returnValue = 100 - RR + '%';}
}

return returnValue;

Aucun commentaire:

Enregistrer un commentaire