Array don't get values

Hello, i had this code

var existingFloor = app.root.findByName("Floor");

but if gave me undefined so i thought if it didn’t find any Floor entity didn’t work so i have changed in

var existingFloor = [];
existingFloor = app.root.findByName("Floor");

but nothing change so when i check the length i have an error coz it’s undefined…
lines 386 and follows

Have you debugged you code?

Adding breakpoint on existingFloor = app.root.findByName("Floor"); line and checking what value existingFloor will have after that line executed will give you a hint.

You assign value to variable, means you are redefining it.
Don’t forget to complete whole course on CodeAcademy on JS: As you are making simple JavaScript related mistakes that is basic to the language it self, not related to PlayCanvas.

Found the error 3 lines upper the one u mantioned…thanks for your kindness @max :slight_smile: