How to grab the first item in the array after using split

Here is my code. I am trying to grab the first element in the array after the split. After the split the first alert returns '2012, 0' and the second alert returns '0'. I want to grab the '2012'. Does anyone know how I would do that?

    var today = new Date();     
    var currentYear = today.getUTCFullYear();       
    var ratingsData = [];
    var ratingsArray= [];
    var ratings = iGetElementsByClassName("empRatings", document, "DIV");

for (x=0; x<ratings.length; x++){
        ratingsData[x] = ratings[x].innerHTML.split("/");
        ratingsArray[x] = ratingsData[x][1];



JavaScript arrays are zero indexed, use zero to get the first item:

ratingsArray[x] = ratingsData[x][0];

"split" returns an array, and you store the entire array in a single variable, then show this array in its entirety.

Use this instead:


-- it only shows the first value in the returned array.

Need Your Help

Web browser doesn't search total ACE editor

php editor ace-editor

The search functionality(Ctrl+f) of the web browser does not properly work when editing a file in the ace editor.

Sencha touch 1 - Left Slide Menu

ios cordova sencha-touch

I am trying to do some enhancements on an existing app developed using sencha touch.The app was fully developed in Sencha Touch and the new change is to add a Left slide menu like in Facebook app.Is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.