Does a Timed Loop count as a form of iteration for the AP Create PT?

Greetings @nick.bahr,

as per your inquiry a timedLoop could count as an iterator, However trying to make a case that it does iterate will be much more challenging for a student to prove at least over using conventional means. In order to explain what i mean it may be able to show better with an example

var array = [1,2,3,4,7,8,21];
// lets start with a conventional statement
for(var i = 0; i < array.length; i++) {
 console.log(array[i]);
}
// now for the more unconventional iterator
var i = 0; // needs a seperate iterator outside
var iterator = setInterval(function(){ // needs an id to stop iterating
 console.log(array[i]);
 if(i < array.length-1) {
  i++;
 } else {
  clearInterval(iterator); // more work that is already implicity done by the for loop 
 }
},100)

as per my definition of an iterator it must have a start and stop point along with a progress tracker of where it is in the current loop, weather it be an index or an element, the second one uses a lot more steps to do what an implicit for loop is doing you can also use while or the do while loop though these may require more steps to get an iterator setup they’ll do the job better here. Recently, thanks to @jdonwells I’ve picked up another trait to my personal best practices. What is most important above all is intent using clear instructions takes much less time to understand and explain to get someone up to speed weather your on a team or asking for help.

Anyways hope this answers your question

Best, Varrience

1 Like