14 Must Know Dev Tools Tricks

JS30 14 must know dev tools tricks Screenshot 20180521 140329

In today’s edition of “Array Cardio” we were working with two arrays, one of people and another of comments.

The people array had birth years associated with their names. The array methods .some and .every were used to determine if some or all of the people were over the age of 19. To detemine the person’s age the current year was retrieved via the Date() instance, the person’s birth year was subtracted from that and what remained was the person’s current age.

In the comments array the .find method was used to find the array index number of an item with an particular id number. .slice was then used to split the array at the point of the item we had found. This was then spread into a new array. I like to think of this as a form of non-destructive array editing. ????