Skip to content
Advertisement

Return Zero If Item Within Array Loop Is Not Available And Arrange Items As Week Days

I have this array:

JavaScript

But I need to display the result as follow:

JavaScript

I have tried the following but it’s showing results for more than 5 days in each week

JavaScript

Thanks in advance for your valuable contributions

Advertisement

Answer

You should check if the given day (key) exists in the array if it is not you should write 0 to the table.

Here is a sample code:

JavaScript

I hope I could help you!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement