Arithmetic Code Error | WordPress.org

[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];
  })();

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer