Flood Fill Clone in JavaScript