var alldivstamp = document.getElementsByClassName("divs");
for(var i = 0; i < array.length; i++){
if(array[i-1].getAttribute("data") > 1){
//error here = TypeError: array[(i - 1)] is undefined
}
}
error output: "TypeError: array[(i - 1)] is undefined"
for(var i = 0; i < array.length; i++){
if (typeof foo !== 'undefined') {
if(array[i-1].getAttribute("data") > 1){
//error here = TypeError: array[(i - 1)] is undefined
}
}
}
this did not fix it
for(var i = 0; i < array.length; i++){
if (typeof foo !== 'undefined' && i < 1 && i > array.length-1) {
if(array[i-1].getAttribute("data") > 1){
//error here = TypeError: array[(i - 1)] is undefined
}
}
}
error here too
undefined value in if statement breaks for loop
here is the data structure
<div class="divs"></div>
<div class="divs"></div>
<div class="divs"></div>
.....
when i=0 it checks for -1 in index
"therefor array index does not exist cousing for loop to stop"
SOLUTION:
for(var i = 0; i < array.length; i++){
if (i > 0) {
if(array(i-1).getAttribute("data") > 1){
//do ...
}
}if(i == 0){
//do ...
}
}
success!
error : (TypeError: "x" is (not) "y")
TypeError: "x" is (not) "y"
Examples:
TypeError: "x" is undefined
TypeError: "x" is null
TypeError: "undefined" is not an object
TypeError: "x" is not an object or null
TypeError: "x" is not a symbol
alldivstamp !== array