Using Javascript
, I created a function as simple as possible that gets a _Array_
of objects Pessoa
(example: {name: "Alex", age: 24}
) that returns a new _Array_
only with Pessoa
objects that have age between 20 and 30 years.
function Pessoa(nome, idade) {
this.nome = nome;
this.idade = idade;
}
var alex = new Pessoa("Alex", 20);
if (idade >= 20 && idade <= 30) {
}
I think it's a little wrong, could anyone help me?