speed

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
recursiya
function getSum(arr) {
	let sum = arr.pop();
	
	if (arr.length) {
		sum += getSum(arr);
	}
	
	return sum || 0;
}

console.log(getSum([1, 2, 3]));
ready
cycle
function getSum(arr) {
	
	let sum = 0;
	
	while(arr.length) {
	 sum += arr.pop();
	}
	
	return sum;
}

console.log(getSum([1, 2, 3]));
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.