The createArticle function is actually being passed 3 arguments: the item in the array, the index of the item and the array.
articles.map(function createArticle(article, i, arr) {
return `
<div class="article">
<h1>${article.news}</h1>
</div>
`
});
Your code is just changing the createArticle function from an anonymous function into a named one.
articles.map(createArticle);
function createArticle(article, i, arr) {
return `
<div class="article">
<h1>${article.news}</h1>
</div>
`
}
Since parameters don't need to be declared in JavaScript, your code doesn't include the i or arr parameters.
articles.map(createArticle);
function createArticle(article) {
return `
<div class="article">
<h1>${article.news}</h1>
</div>
`
}
You can see a full explaination and a polyfill (unnecessary these days, but can be helpful when trying to understand a function) on MDN
.mapfunction works: it invokes a specified callback for each element of an array, passing this element into that callback as a parameter.function(item, index, array)... of course, in the callback function you can call those arguments what you like, in this casearticleand you don't have to use the 2nd and 3rd, which is the case