2 回答

TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊
假設(shè)您的數(shù)據(jù)存儲(chǔ)在一個(gè)名為的變量中,mydata那么您可以這樣做:
let newArray = [];
for (const key of Object.keys(mydata)) {
if (key.includes('strIngredient') && mydata[key] !== "") {
newArray.push(mydata[key])
}
}

TA貢獻(xiàn)1872條經(jīng)驗(yàn) 獲得超4個(gè)贊
const getIngredients = (strIngredients) => {
let ingredients = [];
Object.entries(strIngredients).map(i => {
const [key, value] = i;
if (key.includes('strIngredient') && value) {
ingredients.push(value)
} else return
})
return ingredients
}
添加回答
舉報(bào)