James Cat's rough && ready blog

The first recursive function I’ve ever really understood.

Posted in Uncategorized by zzjames on March 1, 2016

In JavaScript

var printDots = function(n) {
    if(n===0) {                     // terminating condition
        return "";                  // terminating value
    } else {
        return "."+printDots(n-1);  // method of construction
    }
}
Advertisements