hi im a newbie and i have a problem with for loops. my code is here
<code>async function claims(epoch){
let epochs = [];
for (let i = 0; i < 10; i++) {
rounds = epoch - i;
const claimable = await contract.claimable(rounds, Account);
const refundable = await contract.refundable(rounds, Account);
(claimable || refundable) === true ? epochs.push(rounds) : 0
console.log(epochs);
}
}
claims()
</code>
<code>async function claims(epoch){
let epochs = [];
for (let i = 0; i < 10; i++) {
rounds = epoch - i;
const claimable = await contract.claimable(rounds, Account);
const refundable = await contract.refundable(rounds, Account);
(claimable || refundable) === true ? epochs.push(rounds) : 0
console.log(epochs);
}
}
claims()
</code>
async function claims(epoch){
let epochs = [];
for (let i = 0; i < 10; i++) {
rounds = epoch - i;
const claimable = await contract.claimable(rounds, Account);
const refundable = await contract.refundable(rounds, Account);
(claimable || refundable) === true ? epochs.push(rounds) : 0
console.log(epochs);
}
}
claims()
But when I run this function, I get the following response:
<code>[100]
[100,99]
[100,99]
[100,99,90]
[100,99,90]
[100,99,90,86]
</code>
<code>[100]
[100,99]
[100,99]
[100,99,90]
[100,99,90]
[100,99,90,86]
</code>
[100]
[100,99]
[100,99]
[100,99,90]
[100,99,90]
[100,99,90,86]
how can i bring only last row ?
[100,99,90,86]
New contributor
rainboy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.