Untitled
unknown
javascript
10 months ago
401 B
12
Indexable
const ogrenci = {
ad: "Ali kaan",
soyad: "Selek",
notlar: [85, 90, 78, 92],
ortalamaHesapla: function() {
if (this.notlar.length === 0) return 0;
const toplam = this.notlar.reduce((sum, not) => sum + not, 0);
return toplam / this.notlar.length;
}
};
console.log(`${ogrenci.ad} ${ogrenci.soyad} adlı öğrencinin not ortalaması: ${ogrenci.ortalamaHesapla()}`);
Editor is loading...
Leave a Comment