@Aadv1k
Posted
Good job on breaking down your JS into functions, that is a good practice, so, here is a simple fix; remove all the other functions and just have a single one getCard(date)
where the date is either daily, monthly or weekly, then simply in your template replace ${item.timeframes.daily.current}
with ${item.timeframes.[date]['current']}
(do this will all the references) and voila
Marked as helpful
@Tuason066
Posted
Hi @Aadv1k,
Thank you so much for your help. It resolves my problem and this will help me to improve my skills.
I just want to ask is this how we can pass a parameter/argument inside of the template string. [parameter/argument] using square brackets?
@Aadv1k
Posted
@Tuason066 in a object there are two ways to get a property, one is by the dot method foo.bar
second is the foo['bar']
to access a key using a variables you have to use the second on foo[variable]
, it doesn't matter if it's in a template string or as-is, feel free to clarify your doubts if you have any more, Im happy to help
@Tuason066
Posted
@Aadv1k
For now this the only question I have. Thank you so much for enlighten me.
Happy coding.