I want to be able to keep a record of the last 3 tweets my system used....
eg: 949271439605190656,9502373
5200118784
1,95285170
0234137601
So each my my js function runs it recieves a new ID... I want array to drop the last one and add the new one so there is only ever 3.
I have this code:
var last3Ids = [0,0,0];
Open in new window
if (Object.keys(last3Ids).length >= 3) {
last3Ids = last3Ids.slice(last3Ids.length - 3, 3);
}
last3Ids.push(element.tweet_id);
Open in new window
But the array goes between having 3 then 4 then 3 then 4 id's
Can someone help why this is happening?
This is great, thankyou!