i cannot understand for the life of me why the loop is not running

my loop doesn’t run, but the rest of the code runs.

const cards = document.getElementsByClassName("floating-cards");

console.log(randomcolor());

for (let i = 0; i < cards.length; i++) { 
    console.log(2);
    cards.style.backgroundColor = "rgb("+randomcolor()+","+randomcolor()+","+randomcolor()+")";
}

function randomcolor() {
    return Math.floor(Math.random() * 255);
}