Hello everyone, I need some help with a code snippet I'm working on. The code retrieves data from Google Sheets which includes addresses and amounts, then stores it in an array of arrays. I want the script to pause for 10 seconds between each iteration as it loops through the array. Here's what I have so far:
const randomArray = [];
for (var i = 0; i < rows.length; ++i) {
let row = rows[i];
randomArray.push(row);
}
for (const data of randomArray) {
setTimeout(() => {
const AddressID = data[0];
const Amount = parseFloat(data[1]);
console.log(AddressID, Amount);
}, 10 * 1000); // Changed the timeout to 10 seconds
}
There are a total of 4 addresses and amounts that need to be processed one at a time with a 10-second interval between them. My current implementation only waits 5 seconds and then outputs all 4 address and amount pairs simultaneously.