javascript - Node.js code being skipped (for) -


i cannot see what's happening here, can enlighten me?

why not entering for? code:

console.log('l:269');  var smallestprice = itempriceall; // start max console.log('itemnames.length, itempriceall: ' + itemnames.length + ' ' + itempriceall); (var y; y < itemnames.length; y++) {     console.log('are fucking kidding me?');     console.log('l:272, itemprice: ' + itemprice[y] + 'houseedge: ' + (itempriceall * houseedge));     if (itemprice[y] >= (itempriceall * houseedge)) {         console.log('l:274');         if (itemprice[y] < smallestprice) {             smallestprice = itemprice[y];              keeping = itemid[y];          }     } }  console.log('l:284'); 

output:

l:269 itemnames.length, itempriceall 23 97 l:284 

in for loop, condition y < itemnames.length, initial value of y undefined. thus, condition falsy. if want numeric comparison, should initialize y numerical value.

i'd suggest var y = 0.


Comments