v1
12/30/2019 by guzmanoj -00
Setup HTML - click to add setup HTML
Setup JS - click to add setup JavaScript
delete caserun single casemove downdrag and drop case


ready



function getIDX(idx, length){
return idx <= length ? idx : getIDX(idx-length, length); 
}


const newArrayLength = 10000;
const sourceArray = [1,2,3, "Hello", "World", 4, 5];
const resultArray = [];
for(let i=0; i<newArrayLength; i++){
resultArray[i]=sourceArray[getIDX(i+1, sourceArray.length)-1];
}
delete caserun single casemove upmove downdrag and drop case


ready



let array = [1,2,3, "Hello", "World", 4, 5];
let length = 10000;
const fromLength = Math.ceil(length / array.length);
let result = Array.from( { length: fromLength }, () => array )
  .flat()
  .slice(0, length);
delete caserun single casemove upmove downdrag and drop case


ready



function* repeatingSequence(arr, limit) {
  for(let i = 0; i < limit; i++) {
    const index = i % arr.length;
    yield arr[index];
  }
}

const generator = repeatingSequence([1,2,3, "Hello", "World", 4, 5], 10000);

const result = Array.from(generator);
delete caserun single casemove updrag and drop case


ready



   function getIDX(idx, length){
    if (length === 1) {return idx};
    const magicNumber = length * (Math.ceil(idx/length)-1);
     return idx - magicNumber;
    }

const newArrayLength = 10000;
const sourceArray = [1,2,3, "Hello", "World", 4, 5];
const resultArray = [];
for(let i=0; i<newArrayLength; i++){
resultArray[i]=sourceArray[getIDX(i+1, sourceArray.length)-1];
}
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN