Implement javascript

Hi. I’m trying to scrape some products’ prices from amazon.com. I’m generating an array of itemIDs using Javascript, but I don’t know how to implement the code into the JSON. Here is my Javascript code:

var itemNum = []; // new empty array
		for (let i = 0; i < 50; i++) {
			do {
				n = Math.floor(Math.random() * (50)) + 1;
				p = itemNum.includes(n);
			if(!p){
				itemNum.push(n);
			}
		}
		while(p);
	}

I’m writing this because I wanted to generate an array without any duplicates (yes, I know the Math.random function, but it has a chance of generating previous numbers). And since I’m a newbie to this software, what I have Googled and tried didn’t work out so far; see my code here:

{
  "Name": "Macro_Installed_By_XModules_Installer",
  "CreationDate": "2023-7-28",
  "Commands": [
    {
      "Command": "executeScript_Sandbox",
      "Target": "var itemNum = []; for (let i = 0; i < 50; i++) {do {n = Math.floor(Math.random() * (50)) + 1; p = itemNum.includes(n); if(!p){itemNum.push(n);}} while(p);}; return itemNum[1]",
      "Value": "v1",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Random Value Is ${v1}",
      "Value": "#shownotification",
      "Description": ""
    }
  ]
}

Please have a look and adjust for me. I appreciate any help you can provide.

don’t use executeScript_Sandbox.
Instead use “executeScroipt” which usually gives you more functionally but also uses the java engine from the webbrowser. So if you use different browsers the might work or not.