https://jsfiddle.net/a5t24gm3/1/
Search thousands of free JavaScript snippets that you can quickly copy and paste into your web pages. Get free JavaScript tutorials, references, code, menus, calendars, popup windows, games, and much more.
JavaScript flex
const people = [ { name: 'Sara', age: 25, gender: 'f', us: true }, { name: 'Mike', age: 18, gender: 'm', us: false, }, { name: 'Peter', age: 17, gender: 'm', us: false, }, { name: 'Ricky', age: 27, gender: 'm', us: false, }, { name: 'Martha', age: 20, gender: 'f', us: true } ];
// Filter every element of this array let women = people.filter(function(person) { // only return the objects that have the key gender equal to f return person.gender === 'f'; }
To test it
Cool tip: In cases like this you can use console.table instead of console.log to get a table as the output instead of getting the object references.
let women = people.filter((person) => person.gender === 'f');
How the New York Times led to the fall of Assad
Anti-semitism by the New York Times actually made Israel safer ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ...
-
code.gs // 1. Enter sheet name where data is to be written below var SHEET_NAME = "Sheet1" ; // 2. Run > setup // // 3....