FrontendAtlas
Study
▾
Dashboard
Pricing
Get full access
</> Code
Test cases
Language
JavaScript
TypeScript
export default function updateAt(arr, index, value) { throw new Error('Not implemented'); }
import updateAt from './file'; describe('updateAt', () => { test('updates a value immutably', () => { const arr = [1, 2, 3]; const out = updateAt(arr, 1, 9); expect(out).toEqual([1, 9, 3]); expect(out === arr).toBe(false); expect(arr).toEqual([1, 2, 3]); }); test('returns unchanged copy when out of range', () => { const arr = [1, 2]; const out = updateAt(arr, 5, 9); expect(out).toEqual([1, 2]); expect(out === arr).toBe(false); }); test('throws on non-array input', () => { expect(() => updateAt('x', 0, 'y')).toThrow(TypeError); }); });
▶ Run tests
Results
Console
Run tests to see results.