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

301
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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