0
Given the following situation:
I need to create a function that receives as parameter (int value and int divisor). The idea is popular an array with the TOTAL of the range passed to the function. That I could do. However, I now need to return the range of these values based on the division between the number passed as parameter and the division value. I will illustrate below:
const sort = (totalImage, totalPeople) => {
let imageList = new Array;
var result;
for (let interval = 1; interval <= totalImage; interval++) {
let intervalValue = parseInt(interval);
imageList.push(intervalValue);
}
result = totalImage / totalPeople;
I tried an approach with the Slice() method, but I was not successful. From now on, I appreciate any cooperation and I hope I have eluded the problem in the best way possible.
Your problem is very unclear. 1º - "The idea is popular an array with the TOTAL range passed to the function."
Esse intervalo é simplesmente o intervalo de valores que vai de 1 a totalImage, correto?
2º - "However, I now need to return the range of these values based on the division between the number passed as parameter and the division value".Qual a relação, exatamente, que tem entre os elementos desse array e a divisão entre os dois parâmetros da função?
– emanoellucas
– Leandro Barbosa
And if the numbers are not an exact division, like Sort(20, 3)?
– Sam
At first, it would be done only with exact division. But in the case of an inaccurate division, the idea was to round down Ceil(), for example.
– Leandro Barbosa