I've written some code and it all worked the news are getting displayed but when i try to work with one of the news it says its undefined
console.log(news);
console.log(news[0]);
even the length of the news is 0
I've written some code and it all worked the news are getting displayed but when i try to work with one of the news it says its undefined
console.log(news);
console.log(news[0]);
even the length of the news is 0
You are seeing a case of the dev tool evaluation being lazy. The output you are seeing in your console is the value of the array when you click on it, not when it was logged.
You can see it for yourself by doing:
console.log(news.length); // == 0
// Wait 2 seconds
setTimeout(() => {
console.log(news.length); // != 0
}, 2000)
Your news
array is empty at the time of the console log.