user3356020
user3356020

Reputation: 119

Displaying return value of a function in JQuery in another function

I have a JQuery which is retunring an array of LockedProjects [] which is decalred as global variable.

var LockedProjects = [];

I wanted to display the values of this array LockedProjects in another JQuery I m accesing this array of values in an alert box to display and separating them with comma. Before displaying that I am checking the length of it.

if(LockedProjects.length>0)
alert(LockedProjecrs.join(,));

'if' condition is passed But It is not displaying any values. Can any one help on this?

Upvotes: 0

Views: 33

Answers (2)

Claudio Redi
Claudio Redi

Reputation: 68400

The default separator for join is , so you could simply do

LockedProjects.join()

The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma.

Upvotes: 0

George
George

Reputation: 36784

join() expects string, you've given it a comma. Also, 'LockedProjects' is spelt incorrectly. I believe it should be:

alert(LockedProjects.join(","));

Upvotes: 1

Related Questions