Learn localStorage by Building a Todo App - Step 58

Tell us what’s happening:

Step 58

You’ve retrieved the task item(s) now, but they still don’t reflect in the UI when the page loads. However, they appear when you add a new task.

To fix this issue, you can check if there’s a task inside taskData, and then call the updateTaskContainer().

Check if there’s a task inside taskData, then call the updateTaskContainer() inside the if statement block.

You should create an if statement with the condition taskData.length .

Your code so far

if(taskData.length!==0){
  updateTaskContainer();
};

below are what I had tried, but none of them work
taskData.length!==0
taskData.length!=0
taskData.length>0
taskData.length>=1

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 58

@twghydc4b01

Hey there,

The catch here is, the taskData.length can take any value from 0, 1, 2, 3, 4, and so on, and of all the value that it can take, there is only one falsy value, that is 0. The remaining all values correspond to truthy value. Also, it is a well known fact that the if statement passess for truthy value and fails for falsy values. Now go through the below line again and I hope you crack it !

You should create an if statement with the condition taskData.length

While your solution is completely fine and does the required task, this step demands you to do it in a less verbosal way.

Happy Coding :keyboard: !

1 Like

It doesn’t ask for that in the text though. The way it is worded makes it sound like any solution you can come up with should pass (I can think of at least 6 ways of writing it, 10 if you count the different orders of checking the value).

It is just because we are using a regex.

Any valid solution should pass, or the text should specify the solution it requires.

Current hint:

You should create an if statement with the condition taskData.length.

Maybe this instead.

You should create an if statement with (taskData.length) as the condition. As a reminder, 0 is a falsy value.


1 Like