My game's Inventory Codes, will they work?

Here are the codes to the player’s inventory, as well as the player’s health, hunger, and thirst. Will something like this work? Also later on, there will be a GUI linked to the PlayerInventory array. If this will not work, tell me how can it be fixed. Thanks.
PlayerInventoryCodes.

Also wondering, how do people code the game to open a GUI? Then how will I get it to display a picture of the item in the PlayerInventory array? How can I code the array to only hold up to 9 items? Here would be a priority that I need to know: once the inventory codes work, how will I get it to where each of the 9 items in the inventory corresponds to the number keys 1 - 9? I need to get it to where when one of those keys are pressed that the ItemInMainHand’s name changes to the name of that item.

Ok, first, one question at a time. Asking them all at once crashed my brain and I couldn’t understand or remember any of it. For opening the GUI, you could base it off a true/false variable,
var ui = false;
then use the E key to open it,
if (app.keyboard.isPressed(pc.input.KEY_E)) {
a = true;
}
then set your visibility with the variable,
this.(name of ui).setVisibility(ui);
If you want it to be image based, talk to Ayrin.

Hey Allan, don’t start pointing at me as reference lol
I am still learning too so can’t be of much help, and an inventory can be made in several ways, switching scenes with keys or loading an html, or just a bar that show the objects, since they are just 9 i guess that will be the best option, you could study and modify the code of Walking around project in this case, in the other case…i am still studying that too. You can study html/css tutorial in this case.