I try to code a TextAdeventure and I want that a value is added by one so the program can continue with the array of part2 , then part3 and so on.
The program is showing the first part (array1) correctly. Then the value is added by 1 and the program should show the second part (array2), but it is still showing part 1. The arrays are called "part1", "part2", and so on.
When I console.log the variable "partvalue", then it shows "part2", but nevertheless the function is working with "part1". Thanks for helping.
var iCounterText = 0;
var value = 1;
var partvalue = eval("part" + value);
var verzog = setInterval(function(){
if (iCounterText < partvalue.length-3) {
++iCounterText;
toggleText.insertAdjacentHTML('beforeBegin', '<br>--------------<br>' + partvalue[iCounterText]);
playaudio();
}
else {
buttonLinks.innerHTML = partvalue[partvalue.length-1];
++value;
iCounterText=0;
buttonLinks.style.visibility = "visible";
clearInterval(verzog);
}
},500);