Méthode dans une classe qui retourne undefined
Bonjour,
j'ai une classe avec la methode suivante :
Code:
1 2 3 4 5 6 7 8 9 10
| tempsCompose(id, iPre, temps) {
if(this.pronomsP[iPre] ==='noi' || this.pronomsP[iPre] ==='voi' || this.pronomsP[iPre]==='loro') {
document.getElementById(id).innerHTML+=
`${this.pronomsP[iPre]} ${temps} ${this.participe.participePasse[2]}(e) <br>`;
} else {
document.getElementById(id).innerHTML+=
`${this.pronomsP[iPre]} ${temps} ${this.participe.participePasse[1]}(a) <br>`;
}
} |
pour l'affichage dans une boucle :
Code:
verbe.tempsCompose('passeCompose', i, verbe.indicatifEtre.present[i]);
Je souhaiterais ne pas avoir document.getElement... dans ma méthode donc j'ai essayé de la manière suivante mais j'ai undefined
Code:
1 2 3 4 5 6 7 8
| tempsCompose(iPre, temps) {
if(this.pronomsP[iPre] ==='noi' || this.pronomsP[iPre] ==='voi' || this.pronomsP[iPre]==='loro') {
`${this.pronomsP[iPre]} ${temps} ${this.participe.participePasse[2]}(e) <br>`;
} else {
`${this.pronomsP[iPre]} ${temps} ${this.participe.participePasse[1]}(a) <br>`;
}
} |
Code:
1 2
| document.getElementById('id').innerHTML+=
verbe.tempsCompose(i, verbe.indicatifEtre.imparfait[i]); |
Pouvez vous me dire pourquoi j'ai undefined avec la deuxième méthode ?
merci