-2
I have a question, I need to create a function that receives a Array
of people objects, which returns a new array only with person objects that are between the ages of 20 and 30.
Can someone help me if possible?
function pessoa(objec) {
var olders = objec.filter(function(person){
return person.age >= 20 && <= 30;
});
return olders;
}
It’s right that way?
Welcome to Stackoverflow in English. A good practice to start a healthy discussion is to read the Guide to How to Ask. Start by following these recommendations, especially knowing what types of questions to ask, how to create a minimal example that is complete and verifiable, and even what to do when someone answers you.
– Woss
The language itself has a function for this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
– bfavaretto
What have you done about it? Edit your question and put the code of what you did to get better help
– Marcelo Diniz
Function pessoa(objec) { var olders = objec.filter(Function(person){ Return person.age >= 20 && <= 30; }); Return olders; }
– F.Martins