I am learning ES6, so bear me please.
Following is the code which is running fine, if I click the Run button one time, but on second hit it starts showing TypeError: redeclaration of let myArr
error.
Let me know about this weird (may be not) behavior.
let myArr = [34,45,67,2,67,1,5,90];
let evenArr = [];
let oddArr = [];
myArr.forEach(x => {
if (x % 2 === 0) {
evenArr.push(x);
} else {
oddArr.push(x);
}
});
console.log(evenArr);
console.log(oddArr);
Error -