Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
Uncaught SyntaxError: redeclaration of const check

I am working in django and i have written a simple code for dark and light theme, it is working perfectly, but when i inspect my page, it shows an error 'Uncaught SyntaxError: redeclaration of const check', so this is my js code, please tell me how i get rid of this error.

const check=document.getElementById("check")

if (localStorage.getItem('darkMode')===null){
    localStorage.setItem('darkMode', "false");
}

const link = document.createElement('link');
link.rel = 'stylesheet';

document.getElementsByTagName('HEAD')[0].appendChild(link);

checkStatus()

function checkStatus(){
    if (localStorage.getItem('darkMode')==="true"){
        check.checked = true;                           
        link.href = './static/css/modes/dark-mode.css';                   
    
    }else{
        check.checked = false;                         
        link.href = './static/css/modes/light-mode.css';
    }
}

function changeStatus(){                                
    if (localStorage.getItem('darkMode')==="true"){     
        localStorage.setItem('darkMode', "false");      
        link.href = './static/css/modes/light-mode.css';
    } else{
        localStorage.setItem('darkMode', "true");       
        link.href = './static/css/modes/dark-mode.css';
    }
}

please help me

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda