First Last

beginner3 of 4

Learn about first last in fp-ts semigroup

Code Editor

03-first-last.exercise.ts

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

Test Results

Requirements

describe('Semigroup first, last, min', () => {
  it('gets first value', () => {
    const result = getFirstValue([1, 2, 3, 4, 5])
    expect(result).toBe(1)
  })

  it('gets last value', () => {
    const result = getLastValue(['a', 'b', 'c', 'd'])
    expect(result).toBe('d')
  })

  it('gets minimum number', () => {
    const result = getMinNumber([5, 2, 8, 1, 9])
    expect(result).toBe(1)
  })

  it('handles single value', () => {
    expect(getFirstValue([42])).toBe(42)
    expect(getLastValue([42])).toBe(42)
    expect(getMinNumber([42])).toBe(42)
  })
})
🧪

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