How to remove an item from an array forever


I need your help.

Here’s what I get

import wixData from 'wix-data';
$w.onReady(function() {
$w("#text2").text = " ";
function toggleItems() {
$w('#dataset1').onReady(() => {
let coin=$w("#dataset1").getCurrentItem().gCoin;
if (coin===0) {
const ArrayList = ['item1','item2','item3','item4','item5'];
const randomIndex = Math.floor(Math.random() * (ArrayList.length));
$w("#text2").text = ArrayList[randomIndex];

If a random item from ArrayList was shown by $w(“#text2”).text=ArrayList[randomIndex];, I want to make remove the item from ArrayList forever.
But I can get reach.
I use splice() but it didn’t work. It actually remove the item from ArrayList, but ArrayList has 5 item again when I re-run function toggleItems.
So, I think I need to use database, but I don’t know how to handle it well.
When I searched about this problem, people said use wixData.query(). But I can’t get anything. if I use wixData.query(), there is an error message: the collection doesn’t exist.

Is there anybody to help me?

OK, have not tried this, but how about moving the const ArrayList = [‘item1’,‘item2’,‘item3’,‘item4’,‘item5’]; to the position below the “import” and above the $w.onReady( function () {?

let ArrayList = ['item1','item2','item3','item4','item5'];//global scope outside the function
//inside the function:
const randomIndex = Math.floor(Math.random() * (ArrayList.length));
$w("#text2").text = ArrayList[randomIndex];
ArrayList  = ArrayList.filter(e => e !== $w("#text2").text);