I am passing tasks.title ...[] is not getting displayed in this forum editor 🙂
sriramj you should wrap your code in triple backticks. This time I've applied manual edit to your code snippet.
Speaking of your code, you can try a couple of things:
Object.keys(tasks[i])[1]
solution.js
Hi This is my code. Not sure how the output should be. Can you please help ? export const formatTaskList = (tasks) => { for (let i = 0; i < tasks.length; i++) { if (tasks.status == 'DONE') { tasks = '\u2705' + ' ' + 'title: ' + tasks.title; } else { tasks = '\u274c' + ' ' + 'title: ' + tasks.title; } } return tasks; }
chaitanya the mistake is here:
tasks = '\u2705' + ' ' + 'title: ' + tasks.title;
tasks is an array, tasks[0] is the first element of this array, tasks[1] is the second one, and so on.
tasks
tasks[0]
tasks[1]
Try working with tasks[i] as it holds the array element you're interested in.
tasks[i]
I think , when i copy the code here, it removes the brackets from the code..
for (let i = 0; i < tasks.length; i++) { if (tasks[i].status == 'DONE') { tasks[i] = '\u2705' + ' ' + 'title:' + tasks[i].title; } else { tasks[i] = '\u274c' + ' ' + 'title:' + tasks[i].title; } } return tasks;
Now it has copied correctly
.Could you please help to understand what the ouput should look like ??..it is still giving me error on #5 5. Each element of the array returned from formatTaskList should include the task title
`export const formatTaskList = (tasks) => {
for (let i = 0; i < tasks.length; i++) { if (tasks[i].status == 'DONE') { tasks[i] = 'id: ' + tasks[i].id + ' ' + 'title: ' + '\u2705' + tasks[i].title + ' status: ' + tasks[i].status; } else { tasks[i] = 'id: ' + tasks[i].id + ' ' + 'title: ' + '\u274c' + tasks[i].title + ' status: ' + tasks[i].status; }
}
return tasks;
} `
Hi, Can you please give me a hint. I tried the above code as well. But no luck.
I got it finally .. 😃 ... Task 147 is closed.
chaitanya congrats on getting there on your own. Some tasks take a bit longer than the other, but eventually the ones that you struggle with are the ones you learn the most from.
kerstman hey pls which was the solution after all?
eri it depends on what your problem is. I don't reveal the "canonical" solution as copy-pasting won't do any good for you.
Coderslang_Master Error nr.5 Each element of the array returned from formatTaskList should include the task title
eri Could you create a new discussion and post your code there?
Coderslang_Master It is okay. I figured it out. 😀 Thank you for your support!