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

284
Views
Uncaught TypeError: setting getter-only property "selectedProjectId"

Trying to set this variable to an element's id number, but I can't make sense of this error statement.

{Uncaught TypeError: setting getter-only property "selectedProjectId"}

I declared the variable here.

const LOCAL_STORAGE_LIST_KEY = 'project.lists';
const LOCAL_STORAGE_SELECTED_LIST_ID_KEY = 'project.selectedProjectId';
const projects = JSON.parse(localStorage.getItem(LOCAL_STORAGE_LIST_KEY)) || [];
const selectedProjectId = localStorage.getItem(LOCAL_STORAGE_SELECTED_LIST_ID_KEY);

function save() {
    localStorage.setItem(LOCAL_STORAGE_LIST_KEY, JSON.stringify(projects));
    localStorage.setItem(LOCAL_STORAGE_SELECTED_LIST_ID_KEY, selectedProjectId);
}

export {
    projects,
    save,
    selectedProjectId,
}

I try to assign it a different value here.

projectList.addEventListener('click', e => {
    if (e.target.tagName.toLowerCase() === 'li') {
        console.log(e.target.dataset.projectId);
        console.log('works');
        selectedProjectId = e.target.dataset.projectId;
        saveAndRender();
    }
});

I'm following webdev simplified's tutorial on a better to-do-list in js. I'm following pretty closely, but mine keeps throwing the type error. How do I fix this? Any advice would be helpful. For more clarification, I am also using webpack if that is important.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const cannot be assigned to a new value. Use let instead.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

about 4 years ago · Juan Pablo Isaza Report
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!