function createUl(ulSize, depth, maxDepth){
var ul = document.createElement('ul');
for (var i = 0; i < ulSize; i++){
var li = document.createElement('li');
ul.appendChild(li);
li.textContent = 'Hi ' + depth + '.' + i;
if (depth < maxDepth){
li.appendChild(createUl(ulSize, depth + 1, maxDepth));
}
}
return ul;
}
var ul = createUl(10, 1, 6);
document.body.appendChild(ul);
Created
August 14, 2015 02:43
-
-
Save jhoguet/e3b817a45d21f03c21f0 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment