Try setting temp and avgTemp to 0 first:
temp
avgTemp
var temp=0; var avgTemp=0;
In JavaScript, values default to undefined, and undefined + 0.0 == NaN.
undefined
undefined + 0.0 == NaN
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Try setting
temp
andavgTemp
to 0 first:In JavaScript, values default to
undefined
, andundefined + 0.0 == NaN
.