I'm having problems with looping through an array. I'm making an RPG bot for Discord, and I need to display the inventory of the player when prompted. I've tried to use Object.values(), Object.map() and Object.entries(). The names of the items are already worked out with Object.keys(inventory), but the values are the problem.
var invItems = Object.keys(inventory);
var InvValues = Object.entries(inventory);
for (var i = 0; i <= invItems.length; i += 1) {
if (invValues[i[1]] > 0) {
message.channel.send(`${invValues[i[1]]}x ${invItems[i]}`);
}
};
I'm a beginning coder, so please explain more detailed than you usually may do.