Untitled

 avatar
unknown
plain_text
14 days ago
774 B
2
Indexable
const predefinedStations = ["Station 1", "Station 2", "Station 3"];
let recentlyPlayed = [...predefinedStations]; // Always keep predefined stations

function playStation(stationName) {
    console.log(`Playing ${stationName}`);

    // 🔹 CHANGED: Remove station if it's already in the recently played list
    recentlyPlayed = recentlyPlayed.filter(station => station !== stationName);

    // 🔹 CHANGED: Add station to the start of the list (only if it's NOT predefined)
    if (!predefinedStations.includes(stationName)) {
        recentlyPlayed.unshift(stationName);
    }

    // 🔹 CHANGED: Ensure the list contains the 3 predefined stations + up to 8 recent ones
    recentlyPlayed = [...predefinedStations, ...recentlyPlayed.slice(0, 8)];

    updateUI();
}
Editor is loading...
Leave a Comment