The task

Change sum so that it returns the sum of its two arguments. Press Run tests to check your work.

Your code

In an editor, press Ctrl+Enter (Command+Enter on a Mac) to run the tests. Press Tab to move on; the editor does not trap the keyboard.

Starting the code runner…

Results

Run the tests to see the results here.

    This is practice: the result is kept with your attempts and moves your progress, but it does not count towards a certificate.

    The tests

    These tests run in your browser when you press Run tests. You can read them, but not change them here.

    sum.test.js

    import { sum } from './sum.js';
    
    test('adds two numbers', () => expect(sum(1, 2)).toBe(3));
    test('adds negative numbers', () => expect(sum(-1, -2)).toBe(-3));