I ran into a rather weird problem when I try to code a specific part of my bot! To make it simple and short , I have an object array that contains various properties ( see code for examples). What i want to do is I want to get all the specific property in that array ( name for example ) and print that out in a console. I tried looping using a simple for loop , and every successful loop, i asked the console to log arrayname[i].name! See code for clarification!
module.exports = {
commands: ["test"],
callback: (message, arguments, text) => {
const data = [
{ name: "Ren", id: "NURE1" },
{ name: "Isa", id: "SCIS1" }
]
for (var i = 0; i <= data.length; i++) {
console.log(data[i].name)
}
}
}
the problem is it does log the code as expected - Ren and Isa in this case for example but as soon as the console log, the app crashes throwing the error - property name is undefined ;-; - the same goes when i used id. Is there something I am doing wrong??