How to convert data in JQUERY number?

1

When printing a variable it shows me 5 results that I have obtained from the database.

  • General Management.
  • Administrative Assistant.
  • Administration and Human Resources.
  • Finance and Accounting.
  • Advertising and Marketing.

But I would like to know how I can convert these 5 results into a number as such; that is to say, that the console does not print me as such those results but that I tell them.

CODE

for (var j = 0; j < resultado[i].usuario.areas.length; j++)
{                       
    var areas = resultado[i].usuario.areas[j];                      
}   

Thank you.

    
asked by JDavid 24.04.2017 в 16:47
source

1 answer

2

What you do is iterate through all the elements. To get the number of all the elements, you can do it by means of the property length :

resultado[i].usuario.areas.length //sería 5

If what you want is that instead of text, take out the number they would occupy, use the control variable:

for (var j = 0; j < resultado[i].usuario.areas.length; j++)
{                       
    var areas = j+1;  

}   
    
answered by 24.04.2017 / 16:51
source