Of

beginner2 of 10

Learn about of in fp-ts option

Code Editor

02-of.exercise.ts

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

Test Results

Requirements

describe('createUserOptionFromAge', () => {
  const user1: User = { id: 1, name: 'Alice', age: 25 }
  const user2: User = { id: 2, name: 'Bob', age: 30 }

  it('returns some if user has same age as given age', () => {
    const result = createUserOptionFromAge(30)(user2)
    expect(result).toEqual(O.some(user2))
  })

  it('returns O.none if user does not have same age as given age', () => {
    const result = createUserOptionFromAge(20)(user1)
    expect(result).toEqual(O.none)
  })
})
🧪

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