To Undefined

advanced7 of 10

Learn about to undefined in fp-ts option

Code Editor

07-to-undefined.exercise.ts

💻
Loading editor...
Preparing Monaco Editor with TypeScript support

Test Results

Requirements

describe('getAddress', () => {
  const addressOption1: O.Option<string> = O.none
  const addressOption2: O.Option<string> = O.some('123 Main St')

  it('returns undefined if address option is O.none', () => {
    const result = getAddress(addressOption1)
    expect(result).toBeUndefined()
  })

  it('returns the address string in the correct format if address option is some', () => {
    const result = getAddress(addressOption2)
    expect(result).toEqual('123 Main St')
  })
})
🧪

Ready to Test?

Click "Run Tests" to see how your code performs

Pro Tips

💡 Stuck? Here's what to try:

  • • Read the comments in the code carefully
  • • Run tests frequently to get feedback
  • • Check the fp-ts documentation
  • • Use the solution if you need help

🚀 Learning Approach:

  • • Focus on understanding, not just solving
  • • Experiment with different approaches
  • • Think about real-world applications
  • • Build on previous exercises