I have been working through a book on Javascript that includes solved examples, but I've come across one example without a solution. I am interested in learning how to complete it.
The task at hand is to write a script in Javascript (for a browser) that will output even numbers from 1-1000 followed by odd numbers from 1-1000. I am struggling with figuring out how to include a small pause between writing each number and how to detect when the first cycle is complete before moving on to the odd numbers.
This is what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
</head>
<body>
<script type="text/javascript">
/* <![CDATA[ */
var i;
for (i = 0; i < 1000; i++)
if ((i % 2) == 0)
document.writeln(i);
/* ]]> */
</script>
</body>
</html>