Error when instantiating object [not defined]

Asked

Viewed 52 times

1

I was doing a simple exercise, but when using the object appears as undefined...

  class Aluno{
        constructor(paramNome, paramNot1, paramNot2) {
            this.nome = paramNome;
            this.nota1 = paramNot1;
            this.nota2 = paramNot2;
        }

        calcularMedia = (nota1,nota2)=>(nota1+nota2)/2;
        imprimirBoletin = ()=>console.log(`${this.nome}teve a media de ${this.calcularMedia(this.nota1,this.nota2)} `);
    }

In another file in the same folder

const aluno = new Aluno('Felipe',5,5);
console.log(aluno.imprimirBoletin());  

ERROR :Referenceerror: Student is not defined At object. (c: Users Felip Onedrive Desktop exercises js exercicio03 exercicio03.js:1:77) At module. _Compile (Internal/modules/cjs/Loader.js:701:30) At object.Module. _Extensions.. js (Internal/modules/cjs/Loader.js:712:10) At Module.load (Internal/modules/cjs/Loader.js:600:32) at tryModuleLoad (Internal/modules/cjs/Loader.js:539:12) At function.Module. _load (Internal/modules/cjs/Loader.js:531:3) At function.Module.runMain (Internal/modules/cjs/Loader.js:754:12) at startup (Internal/bootstrap/Node.js:283:19) at bootstrapNodeJSCore (Internal/bootstrap/Node.js:622:3)

[Done] exited with code=1 in 0.293 Seconds

1 answer

2


Browser other questions tagged

You are not signed in. Login or sign up in order to post.