I code in javascript, i would like to declare some variables from string and put it into an array by using .push()
function.
I expected it returns :
[
{ member_id: '472030702465056800' },
{ member_id: '925009553802817500' },
{ member_id: '668595198309171200' }
]
But what i got was unexpected. It replaced all the array index with the new object. Here is my code :
let merits_id_cather = [ 472030702465056800, 925009553802817500, 668595198309171200 ]
let merits_final_container = {};
let merits_final_array = [];
for (let i = 0; i < merits_id_cather.length; i++) {
merits_final_container["member_id"] = `${merits_id_catcher[i]}`;
merits_final_array.push(merits_final_container);
console.log(merits_final_container);
console.log(merits_final_array);
}
it returns in console : console returned
What was wrong with the array? Or is there any mistake i made?