Nth Smallest Element

Find the nth smallest element in an array by sorting in ascending order.

Code

General
[...arr].sort((x, y) => x - y)[n - 1];

Parameters

Array of numbers

Position (1-indexed)

Browser·fetch() may be limited by CORS

More JavaScript Snippets