I'm at the start of the road so bear with me. The issue is presented in the title.The code i'm using is as followed:
var arr = [7, 29, 8, 33, 37, 4, -31, 39, 32, -12, 9];
var even = [];
for (var i = 0; i < arr.length; i++){
if(arr[i]%2 == 0){
even += arr[i];
}
}
console.log(even.length);
The code should just get the even elements from an array and move it to another. When the code is ran, the variable "even" will hold the elements as "8432" instead of [8, 4, 32], which will give me a wrong result in console at the end: "4" instead of "3". I can't figure it out why would behave like this.