Null and Undefined

Null and Undefined
πŸ‘¨β€πŸ’Ό Not every product has all fields filled in. We need to handle missing data gracefully. This is where null and undefined come in.
The difference:
  • undefined - The value hasn't been set (default for uninitialized variables)
  • null - The value was intentionally set to "nothing"
let middleName = undefined // not set yet
const deletedAt = null // intentionally empty
🐨 Open
index.ts
and:
  1. Create discountCode set explicitly to undefined
  2. Create lastPurchaseDate set explicitly to null
  3. Optionally log both variables so you can see their values in the console
  4. Export both variables

Required exports

  • discountCode
  • lastPurchaseDate

Completion criteria

  • discountCode is undefined
  • lastPurchaseDate is null
πŸ“œ MDN - null

Please set the playground first

Loading "Null and Undefined"
Loading "Null and Undefined"