Rectified the errors in your text and initialized the variables.
var current_temp = 20;
var prev_temp = 18;
setInterval(function(){
if(current_temp !== prev_temp){
if((current_temp - prev_temp) > 1 || (current_temp - prev_temp) < 1){
console.log('send information to endpoint for egress');
}
console.log('sending identifier to endpoint');
}
}, 3000);
If you wish to monitor a change of exactly 1 degree, consider using code like this:
var prev_temp = 50;
var current_temp = null;
setInterval(function(){
current_temp = Math.floor((Math.random() * 100) + 1); // generate random number between 1 - 100
if((current_temp - prev_temp) === 1){ // transmit data only when the difference is 1 ??
console.log('send information to endpoint for egress');
}
console.log('sending identifier to endpoint');
prev_temp = current_temp; // update previous temperature with the current one
}, 3000);