JS Methods

Data

An Array of Objects - name and year of birth:

const people = [ { name: 'Wes', year: 1988 }, { name: 'Linda', year: 1986 }, { name: 'John', year: 1970 }, { name: 'Ron', year: 2015 } ];
and a second array - content and ID:
const comments = [ { text: 'Love this!', id: 1 }, { text: 'Super good', id: 2 }, { text: 'You are the best', id: 3 }, { text: 'Ramen in my fav food ever', id: 4 }, { text: 'Nice Nice Nice', id: 5 }, ];

Results

1. Method 'array.prototype.some()'. Condition 1: Is at least an one person in age above 19 y.o. present in provided above array? (true if exists, false if not)



2. Method 'array.prototype.every()'. Condition 2: Are all persons in age above 19 present in array? (true - if all persons in array are above 19 y.o.)



3. Method 'array.prototype.find()'. Condition 3: Find where something is inside in array. (Find by selector: find an Object that has an ID with a number 3).



4. Method 'array.protitype.findIndex()'. Condition 4: Find by index (ID). Remove an object from array with ID = 2.