Skip to content

#111 Using Arrow Functions

Adam Kubiś edited this page Oct 28, 2026 · 1 revision

111 Using Arrow Functions

Create a function that returns the given argument, but by using an arrow function.

An arrow function is constructed like so:

arrowFunc = (/parameters/) =>//code here

Current source and tests | Catalog | Testing and tooling

Run this solution

From the cloned repository root, after installing dependencies:

node "Edabit/111 Using Arrow Functions.js"

Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.

Current implementation and tests

This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.

//Create a function that returns the given argument, but by using an arrow function.
//An arrow function is constructed like so:
//arrowFunc = (/*parameters*/) =>//code here
const arrowFunc = (x) => x
import { assertEquals } from '../testHelper.js';
if (!(String(arrowFunc).includes('=>'))) {
    assertEquals(0, 1, "Your code does not use an arrow function")
}
assertEquals(arrowFunc(3), 3)
assertEquals(arrowFunc("3"), "3")
assertEquals(arrowFunc(true), true)
assertEquals(arrowFunc("test"), "test")

Clone this wiki locally