Modify

intermediate5 of 8

Learn about modify in fp-ts record

Code Editor

05-modify.exercise.ts

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

Test Results

Requirements

describe('Record modify operations', () => {
  it('modifies existing key', () => {
    const record = { a: 10, b: 20, c: 30 }
    const result = incrementKey(record, 'b')
    expect(result).toEqual({ a: 10, b: 21, c: 30 })
  })

  it('handles missing key', () => {
    const record = { a: 10 }
    const result = incrementKey(record, 'z')
    expect(result).toEqual({ a: 10 })
  })

  it('updates value at key', () => {
    const record = { name: 'Alice', city: 'Paris' }
    const result = updateAt(record, 'city', 'London')
    expect(result).toEqual({ name: 'Alice', city: 'London' })
  })
})
🧪

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