My code:
var i;
for (i=1 ; i <= 4; i++) {
var value = "value" + i + " ";
$(document).ready(function(){
document.write(value);
});
}
Output:
value4 value4 value4 value4
Every loop different value string will be generated and in jQuery function should be printed. For some reason it is always printing the same value. I am using similar code structure to process api requests and it is doing exact same thing.
What I want:
value1 value2 value3 value4
Am I doing this wrong or is this not possible to do this way?