I'm new to JavaScript and am trying to write code that does the following:
Write some code that writes "1" to the console, then 1 second later writes "2" to the console, then 2 seconds after that writes "3" to the console, ..., until it gets to "10".
I've tried both the setTimeout and the setInterval + combined with setTimeout and I seem to be getting the same persistent error: document.write can be a form of eval. What does this mean and is there any different way I can code this to achieve the result I'm looking for?
var count = 1;
setTimeout(function () {
document.write(count);
count += 1;
}, 1000;
print {
document.write(10), 10000
});
I understand sometimes this occurs when I have an undefined parameter, but in this case, I believe count is defined?
Based off your problem, I'd go at it a bit differently. This will work, but I'm not completely sure it's what you're looking for