Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4049330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:55:53+00:00 2026-05-20T13:55:53+00:00

I realise this error has been discussed previously, but the solutions to the other

  • 0

I realise this error has been discussed previously, but the solutions to the other questions don’t apply here.

I have an array of integers called indArray and a function called addCommas where the array is cycled through and commas are added to the thousands i.e. 9,000 instead of 9000.

Now, this works perfectly fine, however, I try calling addCommas on a different variable and it gives me this error.

Here is my code:

var string = personData[personID - 1];
var indArray = string.split("|");
var targetTotal = int(indArray[0]) + int(indArray[2]) + int(indArray[4]) + int(indArray[6]);
var currentTotal = int(indArray[1]) + int(indArray[3]) + int(indArray[5]) + int(indArray[7]);

for (var j=0; j<indArray.length; j++)
{
    indArray[j] = addCommas(indArray[j]);
}
targetTotal = addCommas(targetTotal); //these two lines give the above error
currentTotal = addCommas(currentTotal); //the pretty much identical line in the for loop does not

and the addCommas function:

function addCommas(num)
        {
            var x = 1;
            var y = 0;
            var z = 1;
            var c = num.split("");
            if (c.length < 4)
            {
                return c.join("");
            }
            else
            {
                c.reverse();
                do
                {
                    c.splice((x*3)+y,0,",");
                    x++;
                    y++;
                    z++;
                } while (z<(num.length/3));
                c.reverse();
                return c.join("");


                     }
         }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:55:54+00:00Added an answer on May 20, 2026 at 1:55 pm

    the problem is you try to apply the split() method to numbers and integers but that is a String method, so you should convert them to String on cast them as Strings. The other thing is you are trying to use variables as integers, then as strings, then as integers again, it is not good.

    Try strict type your variables, it will make everything clearer.

    Here is a quick reference to AS3 strict typing
    http://www.seattleflashusergroup.com/ref02.htm

    I hope it helps,
    Rob

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise there have been a lot of discussions on this topic, but I
I realize that this question has been asked and has been answered here but
I realise this question has been asking before, but I've yet to find an
I realise this question has been asked 100 times, but i've looked through the
So Heroku has been down all day, of course I didn't realise this until
This is a bit of a vague question I realise, but I've been looking
I realise the info to answer this question is probably already on here, but
I realize this question has been asked before, but I can't get it to
So the teacher has posed this assignment: You have been hired by the United
I realise this question has been asked many times before and I've tried pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.