I try to push() an array properties to another array with for{} loop and when I console log() the outcome I only see the number of properties and not the acual value - The array - “Bob”, “Dylan”, 67
var myArr = ["Bob","Dylan",67];
var total = [];
for(i=0; i<myArr.length; i++){
total.push(i);
}
console.log(total);
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
Your code is adding the values 0, 1, 2 to total (which are indices). You start with i=0 and increment i at each iteration of the for loop, so your total.push(i) is just adding the current value of i during that iteration to total. If you want to add the actual value of myArr, then you must reference it and the index of myArr you want to get.