I am very new in javascript and I am lost with this usecase: I have a function :
function1 (trialNumber, next2Pictures){
1- Display 2 pictures
// 2- When a user clicks on one of the pictures
2-1 write you clicked on picture 1(or 2)
2-2 increment trialNumber
2-3 choose new 2pictues
2-4 Return [newTrialNumber, new2Pictures]
}
I have function2 that calls function1 as far as trialNumber didn't exceed totalTrialsNumber. I have this implementation
function2() {
// 1- instantiate trialNumber and next2Pictures
// 2- loop
while(trialNumber < totalTrialsNumber) {
[trialNumber, next2Pictures]= function1 (trialNumber, next2Pictures)
console.log("trialNumber incremented properly")
}
}
the problem is I don't know how to properly return values from function1 that can be used in the while loop of function2. I really need to increment the trialNumber only when a user clicks on a picture. I have checked some answers online but still can't figure it out.