C
C
CrewCut2016-02-04 17:12:41
JavaScript
CrewCut, 2016-02-04 17:12:41

How to iterate over a multidimensional array in jQuery?

I have an array like this:

[
{
  'variation_id':32961,
  'attributes':{'attribute_razmer':'72', 'attribute_tsvet':'черный'},
  'is_in_stock':false
},
{
  'variation_id':32931,
  'attributes':{'attribute_razmer':'70', 'attribute_tsvet':'черный'},
  'is_in_stock':true
}
]


Given an attribute_size value, I need to loop through the entire array to get the is_in_stock value for each element, where attribute_size == my value from the variable. I know how to do it in php, but I can't figure out how to do it in js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2016-02-04
@CrewCut

If I understand the task correctly, you can use Array.filter(function(element){ ... }) We
check the attributes, if everything fits, we return true.
https://jsfiddle.net/jbd62qzz/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question