looping through an object of objects with arrays
yourArray.forEach(function (arrayItem) {
var x = arrayItem.prop1 + 2;
console.log(x);
});let storeItems = {
eggs: {
price: 3.77, quantity: 30
},
milk: {
price: 2.22, quantity: 23
},
butter: {
price: 2.00, quantity: 22
},
carrots: {
price: 3.00, quantity: 11
},
beef: {
price: 6.18, quantity: 34
},
chicken: {
price: 5.44, quantity: 34
}
};
for(let item in storeItems) {
console.log(`${storeItems[item].quantity} ${item}s each cost ${storeItems[item].price}`);
}
// //OUTPUT:“30 eggs each cost 3.77”
// “23 milks each cost 2.22”
// “22 butters each cost 2”
// “11 carrots each cost 3”
// “34 beefs each cost 6.18”
// “34 chickens each cost 5.44”
Also in JavaScript:
- npm react router dom
- async await promise all javascript
- bodyparser express
- react native onChangeText resize the background image
- tab navigation react-native without title
- js remove space from string
- inline if else javascript
- return an array of strings from an array of objects js
- iframe content zoom in and zoom out jquery
- rebuild android react native
- javascript storage get set item
- react router Link does work
- javascript angle equation of a line
- javascript after dom ready
- set value of input javascript
- javascript onkeydown
- convert nuber into string react js
- how to print in java script
- dockerfile for nodejs
- get textarea value jquery
- attr hidden to show jquery
- react disable eslint errors
- javascript how to check if object property exists
- To do validation for the textbox , radio button and dropdown using jquery