Build a Theme Switcher - Build a Theme Switcher

Tell us what’s happening:

I don’t know what I’m doing wrong. I can’t pass test 27

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Theme Switcher</title>
  <link rel="stylesheet" href="./styles.css">
</head>
<body>
  <button id="theme-switcher-button" aria-haspopup="true" aria-expanded="false" aria-controls="theme-dropdown">Switch Theme</button>
  <ul id="theme-dropdown" role="menu" aria-labelledby="theme-switcher-button" hidden>
  <li role="menuitem" id="theme-light">Light</li>
    <li role="menuitem" id="theme-dark">Dark</li>
  <li role="menuitem" id="theme-blue">Blue</li>
<p id="status" aria-live="polite"></p>
  </ul>
  <script src="./script.js"></script>
</body>
</html>
/* file: styles.css */
body {
  margin: 0;
  font-family: sans-serif;
  transition: background 0.3s, color 0.3s;
}

ul {
  margin: 0;
  padding: 0;
}

li {
  list-style-type: none;
  margin: 10px;
}

#status {
  text-align: center;
  min-height: 20px;
}
/* file: script.js */
const themes = [
  {
     name: "light",
      message: "I love light"
  },
  {
     name: "dark",
      message: "I'm darkness"
  },
  {
    name: "blue",
    message: "worst color"
  }
]
const themeBtn = document.getElementById("theme-switcher-button")
const dropdown = document.getElementById("theme-dropdown")
const body = document.querySelector("body")
themeBtn.addEventListener("click", () => {
  let value = themeBtn.getAttribute("aria-expanded") === "true"
  themeBtn.setAttribute("aria-expanded", String(!value))
  dropdown.hidden = Boolean(value)
})

const light = document.getElementById("theme-light")
const dark = document.getElementById("theme-dark")
const blue = document.getElementById("theme-blue")

const para = document.getElementById("status")

function updateClass(value){
  let arr = []
  if(!arr.includes(value)){
  arr.push(value)
  
  }
  body.classList.add(arr[0])
}

blue.addEventListener("click", () => {
    themes.map((obj) => {
      if(obj.name === blue.textContent.toLowerCase()){
       body.style.backgroundColor = "blue"
       para.textContent = obj.message
      }
    })
      updateClass("theme-blue")

})

dark.addEventListener("click", () => {
  themes.map((obj) => {
     if(obj.name === dark.textContent.toLowerCase()){
            body.style.backgroundColor = "#333"
      para.textContent = obj.message

     } 
  })
        updateClass("theme-dark")
})

light.addEventListener("click", () => {
    themes.map((obj) => {
      if(obj.name === light.textContent.toLowerCase()){
              body.style.backgroundColor = "white"
      para.textContent = obj.message
      
      }
    })
  updateClass("theme-light")
      
})

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Mobile Safari/537.36

Challenge Information:

Build a Theme Switcher - Build a Theme Switcher

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-theme-switcher/687ad7be1ff45032ccf1d92f.md at main · freeCodeCamp/freeCodeCamp · GitHub

Sorry please it was step 28 not 27

I already figured it out. :blush::blush::blush: