0

I have an array called: "additions_colorizing_items". It has objects inside it, as seen below:

    var additions_colorizing_items = [
    '',
    {
        "name": 'viking_helmet',
        "actual_name": 'Viking Helmet',
        "rows": 4,
        "first_color": '#ED2C2B',
        "started_color": 4,
        "type": 'H',
        "type_in_words": 'head',
        "have_shadow_now": 'always',
        'need_shadow': false
    },
    {
        "name": 'hard_hat',
        "actual_name": 'Hard Hat',
        "rows": 4,
        "first_color": 1,
        "started_color": '#F6EB56',
        "type": 'H',
        "type_in_words": '',
        "have_shadow_now": 'always',
        'need_shadow': false
    }, ....]

The problem is that $.inArray function doesn't work in this case:

this_id = 'viking_helmet';
alert(additions_colorizing_items[$.inArray(this_id, additions_colorizing_items.name)].actual_name);

The goal is: turning name to actual_name from the same object inside the array for example: viking_helmet -> Viking Helmet

10
  • 1
    Welcome to Stack Overflow! Please take the tour, have a look around, and read through the help center, in particular How do I ask a good question? Please search thoroughly before posting. More on searching here. Commented Dec 16, 2017 at 16:09
  • thank you! I created this account just for this one simple question. I'd like to know if it's possible to do it, and if so how? Commented Dec 16, 2017 at 16:11
  • Anyways, I did enough searching in the interenet and didnt find an answer to my question. Commented Dec 16, 2017 at 16:12
  • oh my gosh you can't do this to me! This isn't a duplicate and the thing you've doesn't work propely for me! :L Commented Dec 16, 2017 at 16:27
  • Maybe better duplicate: stackoverflow.com/questions/1758937/… So, using of grep can help, and commented is one of possible vanilla js solutions: jsfiddle.net/c1roky6e P.S. If i understand your requirement correctly...:) Commented Dec 16, 2017 at 16:32

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.