I'm just starting to learn JS. I need to redo this function into an explicit one. As a result, the property should be added to the object. And please explain how it works.
const newPost = (post, addedAt = Date()) => ({
...post,
addedAt,
})
const firstPost = {
id: 1,
name: 'Max'
}
console.dir(newPost(firstPost))
That's all I could think of. There are no further ideas
const firstPost = {
id: 1,
name: 'Bogdan'
}
const newPost = (addedAt = Date(), ...post) => {
return post
}
newPost(firstPost)