1
i need to do a search inside a javascript object that brings me the sku according to size and color, vcs can give me a light?
Example: I need to insert in a variable the product sku that has the color "Blue" and size "Queen". In this case it would be the SKU 132
var produtos = {
skus:[{
especificacao: {
cor: "Azul",
tamanho: "Queen"
},
sku: 132
}, {
especificacao: {
cor: "Branco",
tamanho: "Queen"
},
sku: 133
}]
};
You can use the Function filter within another Function that gets the color and size. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filtro
– RickPariz
The two answers are good, but the other not marked with is also compatible with Internet Explorer (the one that was checked is not).
– Sam
thanks for the information. As the two worked for me, I will accept your suggestion.
– wbp