javascript – Select random image from an array

I’m trying to make a function where I use math.random. The whole thing is to chose 1 image from an array of 40, and the same number shouldnt be able to be chosen again. Then to be pushed to an img div, how do I go about this the easiest?

    let tempList = allBricks.slice(0);
    let bricks = ();
    for (let i = 0; i < 4; i++) {
        let r = Math.floor(tempList.length*Math.random());
        let ix = allBricks.indexOf(tempList(r));
        imgElems.src = "img/" + ix + ".jpg"; = ix;

This is what I have tried but nothing is happening, well it’s not showing in the correct place. How do I push it to the correct place?