>I can’t seem to figure out how to store the variable for reference in the next frame
You can’t. Expressions have no memory. There’s no way for a variable to survive from frame to frame. What an expression can do, is examine previous pre-expression values, using .valueAtTime() to re-create previous calculations. This is a an expression I have in the archive that implements a vu meter with a 300 ms decay, which you may find useful:
decay = .3; // 300 ms
a = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
maxVal = a.value;
t = thisComp.frameDuration;
while (t < decay){
temp = a.valueAtTime(time - t);
maxVal = Math.max(maxVal, easeOut(t,0,decay,temp,0));
t += thisComp.frameDuration;
}
maxVal