Basic

beginner1 of 4

Learn about basic in fp-ts monoid

Code Editor

01-basic.exercise.ts

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

Test Results

Requirements

describe('Monoid basics', () => {
  it('sums numbers including empty array', () => {
    expect(sumAllNumbers([1, 2, 3, 4, 5])).toBe(15)
    expect(sumAllNumbers([])).toBe(0) // Returns identity element
  })

  it('joins strings including empty array', () => {
    expect(joinStrings(['Hello', 'World'])).toBe('HelloWorld')
    expect(joinStrings([])).toBe('') // Returns identity element
  })

  it('handles single element', () => {
    expect(sumAllNumbers([42])).toBe(42)
    expect(joinStrings(['solo'])).toBe('solo')
  })
})
🧪

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