X42: frontPiece

Given an int array of any length, return a new array of its first 2 elements. If the array is smaller than length 2, use whatever elements are present.

Examples:

frontPiece({1, 2, 3}) -> {1, 2}
frontPiece({1, 2}) -> {1, 2}

Your Answer:

Feedback

Your feedback will appear here when you check your answer.