Sobes.tech
Junior — Senior

Object type determination: duck vs goose

livecode

Task condition

You need to find out how to ensure that the variable bird is of type Duck, and not of type Goose, by using a structure check.

 type Goose = {
  bite: VoidFunction;
  color: string;
};

 type Duck = {
  bite: VoidFunction;
  weight: number;
};

const bird = Math.random() > 0.5
  ? { bite: () => console.log('ow!'), color: 'white' }
  : { bite: () => {}, weight: 32 };

// Implement a check to verify that the object is exactly a duck