Title: Arithmetic Code Error
Last modified: August 16, 2023

---

# Arithmetic Code Error

 *  Resolved [fibbu](https://wordpress.org/support/users/fibbu/)
 * (@fibbu)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/)
 * 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?
 *     ```wp-block-code
         (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];
         })();
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16976592)
 * Hello [@fibbu](https://wordpress.org/support/users/fibbu/)
 * Please, edit the lines of code:
 *     ```wp-block-code
       var inputValues = jQuery('[name="fieldname37"]').val();
       ```
   
 * As:
 *     ```wp-block-code
       var inputValues = fieldname37;
       ```
   
 * And
 *     ```wp-block-code
       return [arithmetic];
       ```
   
 * As:
 *     ```wp-block-code
       return arithmetic;
       ```
   
 * Note you have no control over the values entered by users. They can use spaces
   between commas and numbers, currency symbols, or even changes of lines because
   you say to use a textarea control. So, you must preprocess the values entered
   by users before splitting them.
 * Best regards.
 *  Thread Starter [fibbu](https://wordpress.org/support/users/fibbu/)
 * (@fibbu)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16976883)
 * So, do you have a better solution? Something we will do for this calculation 
   tool without using textarea?
   [Sample](https://miniwebtool.com/arithmetic-mean-calculator/)
 * This is the site I took as an example.
   Thanks.
 *  Thread Starter [fibbu](https://wordpress.org/support/users/fibbu/)
 * (@fibbu)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16977081)
 * I have written rules in the form of counting the numbers entered outside of the
   digits and counting the number of elements entered other than the numbers in 
   the same way. Thanks.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16977200)
 * Hello [@fibbu](https://wordpress.org/support/users/fibbu/)
 * Do you have applied the recommended modifications? Is your equation working fine
   now?
 * Best regards.
 *  Thread Starter [fibbu](https://wordpress.org/support/users/fibbu/)
 * (@fibbu)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16977257)
 * Yes, yes, I ran it, I added letter character rules, it’s working fine now, thank
   you for your attention.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16977348)
 * Excellent !!!
 * Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Arithmetic Code Error’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/arithmetic-code-error/#post-16977348)
 * Status: resolved