I'm a student learning javascript, I'm having a very basic problem. I have to write a script that outputs XHTML text that keeps displaying in the browser window that multiples of the integer 2. How do i get it to display on the screen?
Tags: infinite loop, markup language, HTML element, web page, Technology Internetjavascript infinite loop, output xhtml, xhtml for loop
{ 1 comment… read it below or add one }
Just write a method with infinite recursion, but which multiplies by, and then increments an external variable.
wow, that’s actually so not helpful..sorry, whenever I learn anything, especially computer stuff, it always irritates me loads when people explain things ( such as an infinite loop ) in terms of other words and concepts I clearly don’t know about ( such as infinite recursion ). Yet I STILL catch myself doing it all the time. =/
I mean, if you knew what infinite recursion was, you wouldn’t ask this question! =P
let me give you a less concept heavy explanation.
int multiple;
multiple = 1;
function stuff {
// insert other stuff function is supposed to do
2*multiple; // multiplies by the next multiple in the list
multiple ++;
// or, if they’re Specific multiples of the integer 2 you’re supposed to output, make an algorithm(
// eg. multiple = multiple +2; gives you every second one
stuff () // this is what causes the recursion. the method calls itself so the loop never breaks or ends
}
You must log in to post a comment.