My code is working fine in every browser except for IE. I'm unsure how to fix the issue.
I am trying to remove an item from one array and place it at the top of another array.
Currently, I have an array of articles where some are marked as hero and others are not. I want to locate the first hero article in the array, remove it, and then move it to the beginning of another array.
The error message I am receiving is 'Expected identifier'.
const articles = [
{title: "article 1", hero: false},
{title: "article 2", hero: false},
{title: "article 3", hero: true},
{title: "article 4", hero: false},
{title: "article 5", hero: true},
{title: "article 6", hero: false},
{title: "article 7", hero: true},
];
const heros = [];
for (var [i, article] of articles.entries()) {
if (article.hero) {
heros.unshift(article);
articles.splice(i, 1);
break;
}
}
console.log(heros);
console.log(articles);