troubleshooting Question

JS Array Help

Avatar of Steve Tinsley
Steve TinsleyFlag for United Kingdom of Great Britain and Northern Ireland asked on
3 Comments1 Solution108 ViewsLast Modified:
I want to be able to keep a record of the last 3 tweets my system used....

eg: 949271439605190656,950237352001187841,952851700234137601

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];
if (Object.keys(last3Ids).length >= 3) {
	last3Ids = last3Ids.slice(last3Ids.length - 3, 3);

But the array goes between having 3 then 4 then 3 then 4 id's

Can someone help why this is happening?
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros