Skip to main content

Code Golf · #61 · 2026-06-04

First and last

Difficulty 1/3 · JavaScript

How to play

Write a JavaScript function body that passes all test cases using the fewest characters. Run against examples first, then submit for the full test suite. Eagle < Birdie < Par.

Given an array, return a new array with just the first and last elements.

Examples

f([1,2,3,4,5]) 1,5
f(["a","b","c"]) a,c

Loading your progress...

Your code (function body — receives input)

function(input) { 0 chars
}

Write the shortest JavaScript function body that passes all tests · Back to hub