Untitled
Anonymous
Plain Text
10/03/2025 5:50 PM
592 B
11
Indexable
Never
const ogrenci = {
ad: "Ahmet",
soyad: "Can",
notlar: [75, 80, 90, 85]
};
function ortalamaHesapla(o: { ad: string, notlar: number[] }): number {
let toplam = 0;
for (let i = 0; i < o.notlar.length; i++) {
toplam = toplam + o.notlar[i];
}
if (o.notlar.length === 0) {
return 0;
}
const ortalama = toplam / o.notlar.length;
return ortalama;
}
const ahmetOrtalama = ortalamaHesapla(ogrenci);
console.log(`Öğrenci: ${ogrenci.ad} ${ogrenci.soyad}`);
console.log(`Ortalaması: ${ahmetOrtalama.toFixed(2)}`);Editor is loading...
Leave a Comment