Skip to content
Advertisement

Tag: for-in-loop

Can someone explain this for/in loop to me?

The part that confuses me is the function calculateCartTotal. What I am confused about is how does this loop know to grab priceInCents? for example, if I was to add another value into the object called “weight: 24” assuming that it is 24 grams, how does the object value skip over quantity and weight and just grab priceInCents? Hopefully I

Implement condition in for..in loop

I am looking at for..in tutorial from MDN documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for…in The example iterates over the object’s properties and prints all. I am trying to print only if value of object’s property is 3. Can someone please help me understand where I am going wrong. And also if possible explain. Answer for…in loops can’t have conditions.¹ You have to implement the

Advertisement