Last active
November 14, 2017 09:43
-
-
Save vetri02/574e930d7324a1932075fa5c73b34c16 to your computer and use it in GitHub Desktop.
Add 100000 numbers in lines to DOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayList(array, rootDom){ | |
var arrDom = []; | |
console.log(array) | |
var frag = document.createDocumentFragment(); | |
for (var i=0; i < array.length; i++){ | |
console.log(array[i]); | |
// arrDom.push('<p>'+array[i]+'</p>'); | |
var p = document.createElement("p"); | |
p.innerHTML = array[i]; | |
frag.appendChild(p); | |
} | |
console.log(arrDom); | |
// rootDom.innerHTML += arrDom.join(''); | |
rootDom.appendChild(frag); | |
} | |
var getNumbers = function(start, end) { | |
var numbers = []; | |
for (var i = start; i <= end; i++) { | |
numbers.push(i); | |
} | |
return numbers; | |
} | |
var array = []; | |
for (var i=0; i <100000; i ++){ | |
array.push(i) | |
} | |
var arrayLength = array.length; | |
var arrayremainder = arrayLength % 100; | |
var start = 0; | |
var increment = 100; | |
if(arrayremainder) { | |
} else { | |
var times = arrayLength / increment; | |
console.log(times); | |
if(start+increment < arrayLength){ | |
for (var i =0; i < times; i ++ ){ | |
var num = getNumbers (start, start+increment) | |
console.log(start); | |
console.log(num) | |
arrayList (num , document.getElementById('root')); | |
start = start+increment; | |
} | |
} | |
} | |
//arrayList(allNumbers, document.getElementById('root')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment