Practical

intermediate6 of 6

Learn about practical in fp-ts ord

Code Editor

06-practical.exercise.ts

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

Test Results

Requirements

describe('Ord practical', () => {
  it('sorts tasks by priority then name', () => {
    const tasks: Task[] = [
      { priority: 2, name: 'Review PR' },
      { priority: 1, name: 'Fix bug' },
      { priority: 2, name: 'Deploy' },
      { priority: 3, name: 'Meeting' },
    ]
    const result = sortTasks(tasks)

    expect(result[0].priority).toBe(3)
    expect(result[1].priority).toBe(2)
    expect(result[1].name).toBe('Deploy')
    expect(result[2].name).toBe('Review PR')
  })

  it('checks if value is between bounds', () => {
    expect(isBetween(0, 10, 5)).toBe(true)
    expect(isBetween(0, 10, 0)).toBe(true)
    expect(isBetween(0, 10, 10)).toBe(true)
    expect(isBetween(0, 10, -1)).toBe(false)
    expect(isBetween(0, 10, 11)).toBe(false)
  })
})
🧪

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