Keys Values

intermediate6 of 8

Learn about keys values in fp-ts record

Code Editor

06-keys-values.exercise.ts

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

Test Results

Requirements

describe('Record keys and values operations', () => {
  it('gets all keys', () => {
    const record = { a: 1, b: 2, c: 3 }
    const result = getKeys(record)
    expect(result).toEqual(['a', 'b', 'c'])
  })

  it('checks if key exists', () => {
    const record = { name: 'Alice', age: 25 }
    expect(hasKey(record, 'name')).toBe(true)
    expect(hasKey(record, 'city')).toBe(false)
  })

  it('checks if record is empty', () => {
    expect(isEmpty({})).toBe(true)
    expect(isEmpty({ a: 1 })).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