Average Calculator
-
Hello
Now I want to calculate the average of 4 numbers, but if one of the 4 number values is not entered as a null value, I want it to calculate the average by dividing it by the remaining 3 numbers. So I’m trying to calculate the average. I made a coding at the bottom, but I couldn’t run it, where is the error?
Sample ; 1,2,3,4 average = 2,5
1,2,4 = average = 2,66 (3. field example not entered)
Thanks(function(){ var yaziliortalama; var kutucuk1 = fieldname29; var kutucuk2 = fieldname30; var kutucuk3 = fieldname38; var kutucuk4 = fieldname39; var toplam = 0; var sayac = 0; if (!isNaN(kutucuk1)) { toplam += kutucuk1; sayac++; } if (!isNaN(kutucuk2)) { toplam += kutucuk2; sayac++; } if (!isNaN(kutucuk3)) { toplam += kutucuk3; sayac++; } if (!isNaN(kutucuk4)) { toplam += kutucuk4; sayac++; } yaziliortalama = toplam / sayac; jQuery('#calculation-yaziliortalama').html(yaziliortalama); jQuery('.kriter1-yaziliortalama').html('Yaz?l? S?nav Ortalamas? :'); jQuery('.kriter1-yaziliortalama').html(yaziliortalama); return [yaziliortalama]; })();
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Average Calculator’ is closed to new replies.