I confused what the differences between these 2 options and if there is a better one the parameter in the timeout function is outside
function createPost(){
setTimeout(function(post){
posts.push(post);
}, 2000);
}
at another function parameter inside createPost function
function createPost(post){
setTimeout(function(){
posts.push(post);
}, 2000);
}
Solution:
there are 2 different things and only the 2nd option will work