Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a function that takes an array and returns the largest and smallest elements.

Easy

Problem Statement

Create a function that takes an array and returns the largest and smallest elements.

Sample Input

[3, 7, 1, 9, 4]

Sample Output

{ min: 1, max: 9 }

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Find the largest and smallest elements in an array function findMinMax(arr) { return { min, max }; } console.log(findMinMax([3, 7, 1, 9, 4]));
Log in or sign up to run or submit your code.Log inSign up
Input
[3, 7, 1, 9, 4]
Expected Output
{ min: 1, max: 9 }