Got issue
My javascript array contains dates
for ex. 19.4.2003,28.11.1997,3.1,,29.6,7.11.2008 (date-month-year).
As you can see some of dates are missing ( just ,, ) and some are without a year (for ex. 29.6).
The array above should looks like: 19.4,28.11,3.1,,29.6,7.11
Then I need to find an element and get its index with jQuery.inArray("searchVar", myArr);
The code is below
if (data.response) { //response from social network
var f_cnt = data.response.length;
for(var i=0;i<f_cnt;i++) {
holidaysArr.push(data.response[i].bdate); //pushing date in array
//modify in loop? or call function to modify later?
}
holidaysLoaded=true; // just flag
}
Pushing (ok) -> modifying -> searching for element. Need your help.
UPDATE
While making project understand I need to call social network API more than once so saved data in my array. Check it:
if (data.response) {
friends_data = data.response.sort(sFirstName); //sorting nvm
f_cnt = data.response.length; //count of arrayfields
holidaysLoaded=true; //flag
}
So array has uid, first_name, last_name, bdate atm. Not just bdate as hour ago.
Question is: How to modify all friends_data[i].bdate with match? Empty birthdays have undefined atm. I think I need something like
for(var i=0;i<f_cnt;i++){
friends_data[i].bdate = cutFunc(friends_data[i].bdate);
}
and form cutFunc(param) with checking on undefined, if not it will match with your function?
UPDATE 2 cutFunc should be smth like this:
function cutFunc(param) {
if(param==undefined) return
else return param.match(/\d+\.\d+/g);
}
thank you :)
holidaysArr.push(data.response[i].bdate);toholidaysArr.push(cutFunc(data.response[i].bdate));. Also, I wouldreturn "";from the cutFunc ifparam==undefined.