Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

get Date não funciona

Uncaught TypeError: Cannot read property 'getDate' of undefined(…)

  adiciona(event){
        event.preventDefault();
        let data = new Date(
            ...this._inputData.value
                .split('-')
                .map((item, indice) => item - indice % 2)
        );
            let negociacao = new Negociacao(
                data,    
                this._inputQuantidade.value,
                this._inputValor.value
            );

            let diaMesAno = negociacao.data.getDate()  // não funciona 
                + '/' + (negociacao.data.getMonth() + 1) 
                + '/' + negociacao.data.getFullYear();
            console.log(diasMesAno);
    } 
}
4 respostas

Olá Carlos !

Por favor mostre sua classe negociação.

Att, Junior.

class Negociacao {
    constructor(data, quantidade, valor){
        this._data = new Date(data.getTime());
        this._quantidade = quantidade;
        this._valor = valor;
        Object.freeze(this);
    }
    get Volume(){
        return this._quantidade * this._valor;
    }
    get Data() {
        return new Date(this._data.getTime());
    }
     get Quantidade() {
        return this._quantidade
    }
     get Valor() {
        return this._valor
    } 
}
solução!

Você colocou o nome dos getters em Negociacao começando com maiúscula.

Muito Obrigado Flavio :D

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software