Hello I am struggling with arrays in JavaScript/NodeJS.
Basically, here is my code:
let arr = new Array();
arr = {
"Username" : var1,
"Console" : var2,
"Pseudo" : var3,
}
console.log(arr);
var1, 2 and 3 contains my data that is changing each time.
Let's consider for our first case:
- var1 is "Johnson"
- var2 is "ps4"
- var3 is "Johnson46"
The code above would display the following:
{ Username: 'Johnson', Console: 'ps4', Pseudo: 'Johnson46' }
Now if the data in var1, var2, and var3 change, it will replace the array's content with new data. So if var1 = "Dave", var2 = "xbox" and var3 = "Dave78", it will replace the current array and display:
{ Username: 'Dave', Console: 'xbox', Pseudo: 'Dave78' }
But instead I would like my code to print the follwing:
{ Username: 'Johnson', Console: 'ps4', Pseudo: 'Johnson46' }{ Username: 'Dave', Console: 'xbox', Pseudo: 'Dave78' }
See? Without overriding the array, just adding my data in succession. "line by line" or "step by step" if you prefer, sorry I don't really know how to say that.