⛄Snowberb⛄ – 11-14 Jan 10

Having data.length === 17 and limit === 10, how can I dynamically obtain the result of 3? As data.length and limit can change
UU
Unknown User464d ago
S
Sniberb464d ago
wdym? I just don't know how I can program that if:
data.length === 202 & limit === 10 -> 8
data.length === 56 & limit === 10 -> 4
data.length === 5 & limit === 15 -> 10
data.length === 202 & limit === 10 -> 8
data.length === 56 & limit === 10 -> 4
data.length === 5 & limit === 15 -> 10
E
Enfield-Li464d ago
use &&
if(data.length === 202 && limit === 10) {
return 8;
}
if(data.length === 202 && limit === 10) {
return 8;
}
UU
Unknown User464d ago
S
Sniberb464d ago
please read again the question, that's not dynamically thats hardcoding yes there's logic behind, like obviosuly I dont need it hardcoded, both the length of data and limit can change, without me knowing what their value will be
UU
Unknown User464d ago
S
Sniberb464d ago
lol I thought I had said it on the question, apologies. So if the limit is 10 and the data length is 17, 3 comes out of doing 10 - 7, as there's 10 items listed on each page
data.length === 202 and limit === 10 -> Last page only has 2 items on it, so the difference is 8
data.length === 202 and limit === 10 -> Last page only has 2 items on it, so the difference is 8
UU
Unknown User463d ago