Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Responsive Time Tracking Dashboard

#bem#fetch#sass/scss
Jeffrey Tuason• 550

@Tuason066

Desktop design screenshot for the Time tracking dashboard coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hi,

I need help with my JavaScript.

As you can see in my script I have three functions (dailyCards, weeklyCards, and monthlyCards) I'd like to ask if I can make it only in one function because they have only small differences.

Thank you so much for helping out.

Community feedback

Aadvik• 1,250

@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

2

Jeffrey Tuason• 550

@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?

1
Aadvik• 1,250

@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

0
Jeffrey Tuason• 550

@Tuason066

Posted

@Aadv1k

For now this the only question I have. Thank you so much for enlighten me.

Happy coding.

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord