Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript number possible outcomes of an event Re: number possible outcomes of an event

#99101
Johnnyb
Member

I don’t think this is too hard, it’s just some basic math..

As an example: If you need the average of 13 numbers to be 3, then the total of those 13 numbers needs to be 39 (13 * 3 = 39). So you start off with a variable of value ’39’ (or just ‘what average value needs to be’ * ‘number of inputs’). Every time the user inputs a value between 1-7 then you subtract that number from the total. So if they select ‘7’ for the first input then the new running total is ’32’. Basically all 13 inputs have to total 39. If they have 5 inputs left and the running total is down to ‘5’ then they are restricted to enter only ‘1’ for the final 5 inputs.

I don’t have time to code something out but it doesn’t seem too tricky once you wrap your head around it!