Select X numbers from an array to match given value X

I have a problem to solve in JavaScript and I am not sure where to start.
I will have an array of values.

[1000, 500, 400, 300, 200, 100]

I will be given two numbers

X number of array elements to use.

N Value that the elements must add up to

Sorry but as I don’t know where to start, I do not have any attempted code to share.

Any tips on where to start would be greatly appreciated