Home » Javascript » javascript How to check the same data is available for the second time

javascript How to check the same data is available for the second time

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have a tricky requirement which im not able to fix.

I have a button and if i click on that button, Im getting below data from a REST web service ..

{
"results": [{
            "Reqdate": "\/Date(1520899200000)\/",
            "Tooltip": "13.03.2018 Blood Donation Approved ",
            "Legendid": "GROUP_LEVEL1"
            },{
            "Reqdate": "\/Date(1523836800000)\/",
            "Tooltip": "16.04.2018 Privilege Leave Sent ",
            "Legendid": "BADVALUE_LIGHT",
            },{
            "Reqdate": "\/Date(1524528000000)\/",
            "Tooltip": "24.04.2018 Privilege Leave Sent ",
            "Legendid": "BADVALUE_LIGHT",
            }]

            }

If im getting the above data for the first time. Im going to display one section. Now again if i click on the same button, If i get the same data in the service then i have to hide the section. But im not able to check the same data for the second time.
Im trying to fix this issue by storing the data in a variable like below..

var firstTimeResults = data.results;

Now im not able to check if the same data is coming for the second time. Actually im not able to produce the sample code too. Im sorry for that

Can someone please help me to fix this issue.

Answers: