Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!