var float1 = 12345.00,float2 = 12345.4567,float3 = 12345.982;
var MoreMath = {/*** Rounds a value to the specified number of decimals* @param float value The value to be rounded* @param int nrDecimals The number of decimals to round value to* @return float value rounded to nrDecimals decimals*/round: function (value, nrDecimals) {var x = nrDecimals > 0 ? 10 * parseInt(nrDecimals, 10) : 1;return Math.round(value * x) / x;}}
MoreMath.round(float1, 1) => 12345.0MoreMath.round(float2, 1) => 12345.5MoreMath.round(float3, 1) => 12346.0
debris = string.split("_") //explode string into array of strings indexed by "_"
debris.pop(); //pop last element off the array (which you didn't want)
result = debris.join("_"); //fuse the remainng items together like the sun