Adding weapon inventory array to rpg maker mv choices list

I don't know where to put this, but I don't know why this won't work:
const v = $gameParty.equipItems();
$gameMessage.setChoices(v.name, 0, 1);
or
$gameMessage.setChoices($gameParty.equipItems().name, 0, 1);
I get an error when I try to add it to the choices.
I have no problem adding the array to a message box using a for loop but it the choices get weird if I add them using the loop.
Any help would be appreciated. Thanks.
What is the script for the loop? When exactly is the error thrown, like as soon as the script runs, or when you select a choice, or when you display the choices? And which error is being thrown exactly?

It might also help to know what your desired functionality is, e.g., why you ultimately want to incorporate an array into a choice interface, as someone may be able to point you towards an easier way to accomplish what you need as this way will need you to do a lot of scripting for all potential choices.
I don't know where to put this
I would put it in JavaScript support, as it's not dealing with default functionality of MV.

I don't know why this won't work:
None of them are correct syntax for the setChoices() method. That is expecting the first argument to be an array of strings which are displayed as the individual choices.

$gameMessage.setChoices(v.name, 0, 1);
This isn't correct JavaScript syntax, as your array does not have a "name" member variable. The individual elements of your array do, but this doesn't mean anything.

$gameMessage.setChoices($gameParty.equipItems().name, 0, 1);
This is the exact same as above, just you're not setting it to a second variable unnecessarily (so this is actually more efficient, just also incorrect 😉).

What you need is to produce from the array of items an array of just their names. Luckily, JavaScript has a ton of array functions built-in for you.
Code:
var itemsArray=[];
$gameParty.equipItems().forEach(item => itemsArray.push(item.name)

The forEach() method executes that miniature function on each member of the array. The push() method adds that data to an array.

Then you would just call setChoices() using itemsArray as your first argument.

Note that I'm not sure which is correct, your using equipItems or the words that you used in your post title - this will not show you just weapons, but all equippable items. You could certainly add a conditional to the function above if you really do want just weapons.
Thank-you all for your help.

ATT_Turan,​

your method worked great. The full solution is:

var itemsArray=[];
$gameParty.equipItems().forEach(item => itemsArray.push(item.name))

$gameMessage.setChoices(itemsArray, 0, 1);

It works just like I want it to. Thanks again.

Original thread: https://forums.rpgmakerweb.com/threads/adding-weapon-inventory-array-to-rpg-maker-mv-choices-list.151262/