R
Reactiflux

help-js

⛄Snowberb⛄ – 11-14 Jan 10

S⛄Snowberb⛄1/10/2023
Having data.length === 17 and limit === 10, how can I dynamically obtain the result of 3? As data.length and limit can change
UUUnknown User1/10/2023
Message Not Public
Sign In & Join Server To View
S⛄Snowberb⛄1/10/2023
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
EEnfield-Li1/10/2023
use &&
if(data.length === 202 && limit === 10) {
return 8;
}
if(data.length === 202 && limit === 10) {
return 8;
}
UUUnknown User1/10/2023
Message Not Public
Sign In & Join Server To View
S⛄Snowberb⛄1/10/2023
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
UUUnknown User1/10/2023
Message Not Public
Sign In & Join Server To View
S⛄Snowberb⛄1/10/2023
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
UUUnknown User1/11/2023
2 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!