Hey there! Let’s go through each chat mode and see if it should be locked or not. If the mode is locked and the user doesn’t have the required pro, we’ll create a div element with the chat mode’s label and description. We’ll also add a checkmark icon if the mode is the saved mode. If the mode is unlocked, we’ll just add the div element to the chat mode menu. Here’s the code: ```javascript chatModes.forEach(mode => { const shouldBeLocked = mode.locked && ((mode.value === “genius” || mode.value === “supergenius”) && !userHasPro); const item = document.createElement(“div”); item.classList.add(“chat-mode-menu-item”); item.id = mode.value; if (shouldBeLocked) { item.classList.add(“chat-mode-locked”); item.setAttribute(“locked”, “true”); } const textContainer = document.createElement(“div”); textContainer.classList.add(“text-container”); textContainer.innerHTML = ` ${mode.label} ${mode.description} `; const checkDiv = document.createElement(“div”); checkDiv.classList.add(“chat-mode-checkmark”); checkDiv.innerHTML = checkIconSVG; if (mode.value === savedMode) { item.classList.add(“selected”); } }); ```

Popular Posts