0

I fairly new to javascript and can't figure out the problem with this code

const array1 = [1, 2, 3, 4];
array1.map(squareit);
let array2;

function squareit(no) {
  array2.push(no * no);
}
console.log(array2);

i have feeling my question is silly but still help me pls

this is the error i get Uncaught ReferenceError: Cannot access 'array2' before initialization

Reyno
  • 6,119
  • 18
  • 27
Shubham
  • 13
  • 5

0 Answers0