Im using phantomjs and casperjs to test out my website.
In my JavaScript I have a for loop using var i, and another var rando inside the loop which increments.
I am calling
console.log(i); 
console.log(rando); 
for testing, but it does not print the correct value to the command line. However, I know that the variable is changing, as the code does as intended, for example the for loop is incrementing.
I tried using
console.log("%d", i);
but no luck.
My Code using a suggested solution still no luck:
for (i=0; i<100000; i++) {  //// first loop
casper.wait(13000, function () {
    casper.then(function () {
        console.log(String.valueOf(i));
        console.log(String.valueOf(rando));
        casper.click(x(('/html/body/div[2]/div/div[2]/div/article/div[2]/section[2]/a/span')));
        console.log(timeStamp());     
    });
});
casper.then(function () {
    casper.click(x(('/html/body/div[2]/div/div[1]/div/div/a[2]')));        
});
if (rando == 14) {
    casper.then(function () {
        casper.click(x(('/html/body/div[2]/div/div[2]/div/article/header/span/button')));
        console.log(timeStamp());        
    });
    rando = 0;
} else {
    rando++;
}
}
The result is printing i as 100000 and rando as 10 every time, even when they are incremented.
 
    