Skip to content
Advertisement

How do I include part of my code into ‘yield’?

Thank you for your time!

Each products, sometimes have more than one model. I got the model ‘name’ and ‘price’ of the respective models within a single product via a for loop.

But, how do I ‘transfer’ these details to the ‘yield’ section along with other variables of that same product? Below is my attempt, but i am not getting it correct. How do I edit the code, so that, it could record more than one models (along with the price) within a same product, wherever applicable:

JavaScript

Advertisement

Answer

You should keep your yield inside for loop and if statement. You can try as follows:

JavaScript
Advertisement