You are browsing as a guest. Sign up (or log in) to start making projects!

2h 53m 51s logged

Devlog 5

I possibly made my dumbest programming mistake ever!

My image API gets 15 images each time, now to not have to use the API every time, I deficed that if the user enters the same prompt, the 15 images they already got would be used and just shuffled through. Now to shuffle the array I used

for (let i = 0; i < arr.length * 3; i++) {     
const varPos1 = Math.floor(Math.random() * arr.length);
const varPos2 = Math.floor(Math.random() * arr.length);
const val1 = arr[varPos1];      
arr[varPos1] = arr[varPos2];      
arr[varPos2] = arr[VarPos1];    
}    
console.log(arr);    
return arr;  }

It does not take an expert to find the problem,

So there I sat thinking why when increasing the shown photo ID i kept getting the same image

But now I should not run out of API tokens

0
53

Comments 0

No comments yet. Be the first!