Filter

advanced9 of 10

Learn about filter in fp-ts option

Code Editor

09-filter.exercise.ts

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

Test Results

Requirements

describe('getValidUserAddress', () => {
  it('returns O.none if user has no address', () => {
    const result = getValidUserAddress(O.none)
    expect(result).toEqual(O.none)
  })

  it('returns O.none if user has an address that is too short', () => {
    const result = getValidUserAddress(O.of('456'))
    expect(result).toEqual(O.none)
  })

  it('returns the valid address if user has an address that is long enough', () => {
    const result = getValidUserAddress(O.of('123 Main St'))
    expect(result).toEqual(O.some('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