0
I am learning javascript and am getting the following error: setTitulo is not defined
Why does this error happen? The setTitulo method should not be set since it belongs to the class?
class Nota{
constructor(titulo, descricao){
try {
this.titulo = setTitulo(titulo);
this.descricao = descricao;
} catch (error) {
showError(error);
}
}
setTitulo(titulo){
if(titulo !== null && titulo.length > 0)
return titulo;
else
throw new Error("title", "Title is sadsadsa");
}
}
class Error{
constructor(name, message){
this.name = name;
this.message = message;
}
}
const showError = function(error){
const panelError = document.getElementById("panel-attention");
panelError.innerHTML = `Error: ${error.message}`;
}
Have you tried
this.setTitulo(titulo);
?– Augusto Vasques