My First Payload Parser Script

My First Payload Parser Script

Hello everyone,
I am creating a my first payload parser script, since I am a 'newbie' I can use some help, guidance.

I have a Dragino Sensor, with Two Temp Probes,  I want to accept the readings from the two probes and create a new variable whose value is the difference of these two probe readings.

-----------
My payload parser is as follows:-
const allowonly_vars = ['Temp_White', 'Temp_Red', 'BatV'];
payload = payload.filter(x => allowonly_vars.includes(x.variable));

const tempred = payload.find( x => x.variable === 'Temp_Red');
const tempwhite = payload.find (x => x.variable === 'Temp_White');
if (tempred) {
 const cooling = tempred.value - tempwhite.value
 payload.push({"variable": "cooling", "value": cooling});
}
--------------

it is sort of working.

Q: How can I 'group' the 'cooling' variable value with the Temp_Red & Temp_White ?
(right now my "cooling" variable is not showing the 'group' value).

Q: Can I optimize my code above to be better ?

Thank you very much in advance.