I am working on this code, that take a specifics items of an array to compare:
//print the content inside array 'mensagens'
console.log(mensagens);
//print just the firts 'Classe'
console.log(mensagens[0].Classe);
//put in classeN the result (Classe) of a condition
let classeN = mensagens.find(a => a.TempoInicial <= b.seconds && (a.TempoFinal ??
b.seconds) >= b.seconds).Classe;
The array mensagens is defined out of this code, I just use her here.
The problem is when after the find() method, when i try to take the Classe from array mensagens, the console say that cannot read Classe, because is undefined.
But when I print all the content of the array mensagens, everything seens to be just fine:
Anyone know's how can I acess right after the find() method all that five Classes inside the array?
Please, any help can be good!
CodePudding user response:
Turn out that I have finded wheres the problem is...
When I compare the a.TempoFinal with b.seconds, the a.TempoFinal must be ```null`` not zero, so that is what was causing me troubes... thaks for the help

