0

I've an object and a 1-D array like this:

nodes = {"id": 'Habitat for Humanity', "reflexive": true};
nodes = {"id": 'Caring', "reflexive": true};
nodes = {"id": 'Helping', "reflexive": true};
nodes = {"id": 'People', "reflexive": true};
nodes = {"id": 'Security', "reflexive": true};
nodes = {"id": 'Shelter', "reflexive": true};
nodes = {"id": 'Community', "reflexive": true};
nodes = {"id": 'Volunteering', "reflexive": true};

var sources = ['Helping', 'Community', 'Caring', 'Safety', 'Security'];

I want to find out the index of an element taken from the 'sources' array in the 'nodes' object. For example, the element 'Helping' in the 'sources' array is located at index 2 in 'nodes' object. So I need "2" as my solution when I search for index of the word "Helping". Can somebody help me on this? Thanks.

2
  • 1) Please format your code better 2) do you have 8 objects or one object with an array of 8 items? - You will likely find the answer here: stackoverflow.com/questions/135448/… Commented May 8, 2015 at 5:26
  • 1
    The OP creates 8 objects but assigns them in turn to the same variable named nodes, whose value ultimately is a reference to the last object assigned ({"id": 'Volunteering', "reflexive": true};). Commented May 8, 2015 at 5:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.