Last active
October 29, 2020 14:32
-
-
Save simonjcarr/f15147f9ef14bd850ff3ecff2bb1f8e6 to your computer and use it in GitHub Desktop.
findFilterArrayData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 1, | |
"name": "Joe Bloggs" | |
}, | |
{ | |
"id": 2, | |
"name": "Jane Doe" | |
}, | |
{ | |
"id": 3, | |
"name": "John Doe", | |
"address": { | |
"street": "21 Lime Street", | |
"city": "London" | |
} | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let users = require('./data.json'); | |
let filterDoe = users.filter(user => user.name.includes("Doe")) | |
console.log(filterDoe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let users = require('./data.json'); | |
let findCityLondon = users.find((user) => { | |
try { | |
return user.address.city.includes('London'); | |
} catch { | |
return false | |
} | |
}); | |
console.log(findCityLondon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let users = require('./data.json'); | |
let findCityLondon = users.find(user => { | |
return user.address.city.includes("London") | |
}) | |
console.log(findCityLondon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let users = require('./data.json'); | |
let findDoeUsers = users.find((user) => user.name.includes('Doe')); | |
console.log(findDoeUsers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let users = require('./data.json'); | |
let findId1user = users.find(user => user.id == 1) | |
console.log(findId1user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment