Skip to content

Instantly share code, notes, and snippets.

@priyankaa02 priyankaa02/test.js
Created Jan 26, 2019

Embed
What would you like to do?
finding age between 30 and 40
function peopleArray(listOfPeople){
let filteredArray = []
for ( var i = 0; i < listOfPeople.length; i++){
if(listOfPeople[i].age > 30 && listOfPeople[i].age < 40){
filteredArray.push(listOfPeople[i])
}
}
return filteredArray
}
people = [
{id : "1", name : "abc", gender : "m", age :"15" },
{id : "2", name : "a", gender : "m", age :"25" },
{id : "3", name : "efg", gender : "f", age :"5" },
{id : "4", name : "hjk", gender : "m", age :"35" },
{id : "5", name : "ikly", gender : "m", age :"41" },
{id : "6", name : "ert", gender : "f", age :" 30" },
{id : "7", name : "qwe", gender : "f", age :" 31" },
{id : "8", name : "bdd", gender : "m", age :" 78" }
]
var result = peopleArray(people)
console.log(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.