In example 1, running that results in line 4 being executed and then skipping right over line 5. In example 2, changing line 4 to refer to the actual value rather than an array allows line 5 to be executed.
What can I do to make example 1 work properly? And why does example 2 work and not example 1?
I've used the same for loop in another instance, with a different array, that worked perfectly. So perhaps it's the array itself that's the problem?
1.
var temp2 = rightbarcoderead(i);
for (i = 0; i < 10; i++) {
if (temp2 === righteven[i]) {
rightbarcode += i
}
2.
var temp2 = "100110";
for (i = 0; i < 10; i++) {
if (temp2 === righteven[i]) {
rightbarcode += i
}
rightbarcoderead(i)return you (tryconsole.log(temp2))? Why are you usingithere and then again for theforloop? Why do you think the array is the issue here? Couldn't you just replace this whole loop withrighteven.indexOf(temp2)?