[ad_1]
Hello;
I added a [Text Area]- [fieldname37] field, users enter random numbers in the form of 1,6,9,8.
I also want to calculate the arithmetic average of the digits entered with the code below.
I think I’m making a mistake somewhere in the code, any suggestions?
(function() {
var inputValues = jQuery('[name="fieldname37"]').val();
var numbers = inputValues.split(',').map(parseFloat);
var sum = numbers.reduce((total, num) => total + num, 0);
var count = numbers.length;
var arithmetic= sum / count;
jQuery('#calculation-kriter3').html(arithmetic);
jQuery('.arithmetic-aciklama').html('Arithmetic : ');
jQuery('.arithmetic-sonuc').html(arithmetic);
return [arithmetic];
})();
