This is the rest of the code I have. The bottom is what I have to display the product on the repeater “recommendedProducts.”
function filterProductsPerAnswer ( quizProducts , answer ){
const filteredProducts = quizProducts . filter ( quizProduct => {
return quizProduct . keywords . includes ( answer )
});
return filteredProducts ;
}
function getRandomItemsFromArray ( productsArr , numberOfItems ){
const productIds = ;
let numberOfProducts = productsArr . length ;
**for** ( **let** i = 0 ; i < numberOfItems && i < numberOfProducts ; i ++){
**const** randomIndex = getRandomInt ( 0 , productsArr . length - 1 );
productIds . push ( productsArr [ randomIndex ]);
productsArr . splice ( randomIndex , 1 );
}
**return** productIds ;
}
function getRandomInt ( min , max ){
return Math . floor ( Math . random ()*( max - min + 1 )) + min ;
}
async function getProductsData ( productsIds ){
const productsData = await wixData . query ( “Stores/Products” )
. hasSome ( “_id” , productsIds )
. find ();
return productsData . items ;
}
export function recommendedProducts_itemReady ( $item , itemData , index ){
$item ( '#name' ). text = itemData . name ;
$item ( '#image' ). src = itemData . mainMedia ;
$item ( '#image' ). link = itemData . productPageUrl ;
$item ( '#price' ). text = itemData . formattedPrice ;
}