Sniberb
Sniberb2y ago

⛄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
9 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sniberb
Sniberb2y 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
Enfield-Li
Enfield-Li2y ago
use &&
if(data.length === 202 && limit === 10) {
return 8;
}
if(data.length === 202 && limit === 10) {
return 8;
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sniberb
Sniberb2y 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
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sniberb
Sniberb2y 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
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
reactibot
reactibot2y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1062328522200330240