3 Replies Latest reply on Feb 7, 2007 12:13 PM by thunder_storm

    Undefined Error

    thunder_storm

      for(j=0;j<str.length;j++){

      if (str.charCodeAt(j)<=90&& str.charCodeAt(j)>=65){

      temp=Math.abs((str.charCodeAt(j)-65));
      iNumOfSym[temp]+=1;
      trace(iNumOfSym);

      }

      In the above part code i have declared iNumOfSym as a string... .. but when i run this code and trace iNumOfSym.. i get undefined as the output.. why?? how should i fix it??
        • 1. Re: Undefined Error
          injpix Level 3
          What is it that you are trying to do? iNumOfSym is acting like an object or an array not a string.
          • 2. Re: Undefined Error
            thunder_storm Level 1
            It is acting like an array.. i converted it to array now.. and it will tell me the number of times a character is repeated in a string ( str ) entered by the user. .but instead of giving me a number its giving me NaN as th o/p .. the length of this array is 26 for each alphabet.. and is suppose the user enters 'A' i want the result to look like 1,0,0,...... but instead i m getting .. NaN,undefined,undefined,....
            • 3. Re: Undefined Error
              thunder_storm Level 1
              Ok.. i tried to fix it by initializing each element of the array to zero.. although this is working .. i wanna know if there is a short method to initialize each element of a matrix to zero.. equating the matrix to zero doesnt do it..