Is there a way to apply this JavaScript code specifically to devices with a maximum width of 520px? I could use some guidance on how to achieve this.
// Apply code for max-width = 520px
const myBtn = document.getElementById("darktheme");
const body = document.body;
const welcome = document.getElementById("txtt");
let isDarkTheme = false;
myBtn.addEventListener("click", function() {
isDarkTheme = !isDarkTheme;
if (isDarkTheme) {
body.style.backgroundColor = "rgb(17, 17, 17)";
body.style.color = "white";
welcome.style.color = "white";
} else {
body.style.backgroundColor = "white";
body.style.color = "black";
welcome.style.color = "white";
}
});