# Store a value and compare it with previous value

**URL:** https://discourse.nodered.org/t/store-a-value-and-compare-it-with-previous-value/28369
**Category:** General
**Created:** [15 June 2020 18:29 UTC](https://discourse.nodered.org/t/store-a-value-and-compare-it-with-previous-value/28369 "2020-06-15T18:29:47Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![neelanjan](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@neelanjan](https://discourse.nodered.org/u/neelanjan)
#### Post date: [15 June 2020 19:54 UTC](https://discourse.nodered.org/t/store-a-value-and-compare-it-with-previous-value/28369/10 "2020-06-15T19:54:56Z")

</div>

just tell me onething, i am getting msg.payload.mypath but msg.payload.same is not returning any value...

msg.payload.same = ( msg.payload[0].D[0].value === context.get('hold') ) ? "same" : "not same";  
context.set('hold', msg.payload[0].D[0].value)  
return msg;

---

_[View the full topic](https://discourse.nodered.org/t/store-a-value-and-compare-it-with-previous-value/28369)._
