Skip to content

Instantly share code, notes, and snippets.

@vishalkukreja
Created April 3, 2021 15:05
Show Gist options
  • Save vishalkukreja/258f4bb26bc204867b19228747cf0c1d to your computer and use it in GitHub Desktop.
Save vishalkukreja/258f4bb26bc204867b19228747cf0c1d to your computer and use it in GitHub Desktop.
var empEligibilityDetails = [
{
"name": "Vishal",
"age": 30,
"isManager": false,
"city": "Mumbai"
},
{
"name": "Kunal",
"age": 31,
"isManager": false,
"city": "Pune"
},
{
"name": "Ajay",
"age": 32,
"isManager": true,
"city": "Thane"
},
{
"name": "Rahul",
"age": 36,
"isManager": true,
"city": "Mumbai"
}
];
var empData = empEligibilityDetails.find(value => value.age > 31);
console.log(empData);
//If you want to skip 1st record, you can play with index passed in argument
var empNewData = empEligibilityDetails.find((value, i) => {
if (value.age > 28 && i !== 0) return true;
});
console.log(empNewData);
empEligibilityDetails.find(value => value.age > 31).isManager = false;
console.log(empEligibilityDetails);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment