v1
10/26/2022 by jrsinclair -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const fasterMap = (transform, arr) => {
    const len = arr.length;
    const newArr = new Array(len);
    for (let i = 0; i < len; i++) {
        newArr[i] = transform(arr[i]);
    }
    return newArr;
}

const notSoFastMap = (transform, arr) => {
	const len = arr.length;
	const newArr = [];
	for (let i = 0; i < len; i++) {
		newArr.push(transform(arr[i]));
	}
};

const map = (fn, arr) => arr.map(fn);

const randomStr = () => Math.random().toString(16).substr(2, length);

const myArray = new Array(10).map(randomStr);

const sayHello = str => `Hello ${str}`;
delete caserun single casemove downdrag and drop case


ready



const result = fasterMap(sayHello, myArray);
delete caserun single casemove upmove downdrag and drop case


ready



const result = notSoFastMap(sayHello, myArray);
delete caserun single casemove updrag and drop case


ready



const result = map(sayHello, myArray)
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