Collect
Learn about collect in fp-ts record
Code Editor
03-collect.exercise.ts
💻
Loading editor...
Preparing Monaco Editor with TypeScript support
Test Results
Requirements
describe('Record collect operations', () => {
it('converts record to array', () => {
const input = { a: 1, b: 2, c: 3 }
const result = toArray(input)
expect(result).toEqual([
{ key: 'a', value: 1 },
{ key: 'b', value: 2 },
{ key: 'c', value: 3 },
])
})
it('sums all values', () => {
const input = { x: 10, y: 20, z: 30 }
const result = sumValues(input)
expect(result).toBe(60)
})
it('handles empty record', () => {
const result = sumValues({})
expect(result).toBe(0)
})
})🧪
Ready to Test?
Click "Run Tests" to see how your code performs
Quick Tips
•Read the TODO comments in the code
•Use Reset to restore original code
•Check Solution if stuck
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