As you can see here I have an array of 2 objects which have the same name and other elements, instead of x,y. I'm trying to console log them, and it works just fine, am getting 2 objects. My question is, how do I console.log only one of them, the first one?
var _hero = [{
nick: "Mike",
lvl: 500,
x: 10,
y: 10
}, {
nick: "Mike",
lvl: 500,
x: 15,
y: 15
}]
let main = () => {
_hero.forEach(function(_hero) {
if (_hero.nick == "Mike") {
console.log(_hero);
}
});
};
main();
console.log(_hero[0])