class Pessoa{
nome: string; // variáveis globais
idade: number;
//método construtor
constructor(nome: string, idade: number){
this.nome = nome;
this.idade = idade;
}
// método
verifica_maioridade():string{
return this.idade >= 18 ? "Maior de Idade" : "Menor de Idade";
}
}
// objeto
let p = new Pessoa("João", 20);
console.log(p.verifica_maioridade());
To embed this project on your website, copy the following code and paste it into your website's HTML: