Cannot push a array in js

Not able to push to an empty array. It gives "[] is not a function". How to push into an array?

This is working in one of my apps, could be the lack of semicolon? You are starting on line 19 so its hard to tell.

let datascan = scan.data.Items
let datafiltered = [];

if (switch1.value == true)
{
for (let i = 0; i < scan.data.Count; i++) {
if (datascan[i].backgroundColor == "") {
datafiltered.push(datascan[i]);
}
}
}

if (switch2.value == true) {
for (let i = 0; i < scan.data.Count; i++) {
if (datascan[i].backgroundColor == "green") {
datafiltered.push(datascan[i]);
}
}
}

if(switch3.value == true) {
for (let i = 0; i < scan.data.Count; i++) {
if (datascan[i].backgroundColor == "blue") {
datafiltered.push(datascan[i]);
}
}
}

return(datafiltered)