Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Find the outlier number
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Browser:
Chrome 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Test1
20590990.0 Ops/sec
Test2
5608173.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); } /* findOutlier([1,3,5,7,9,11,13,15,2]); findOutlier2([1,3,5,7,9,11,13,15,2]); */ function findOutlier(integers){ odd = []; even = []; outlier = -1; for (let x = 0; x < integers.length; x++) { let num = integers[x]; if(num % 2 === 0 || num === 0) { odd.push(num); } else { even.push(num); } if(integers.length - 1 === x) { outlier = Number((odd.length === 1) ? odd : even); } } return outlier; } function findOutlier2(int){ var even = int.filter(a=>a%2==0); var odd = int.filter(a=>a%2!==0); return even.length==1? even[0] : odd[0]; }
Tests:
Test1
findOutlier2([2, 4, 0, 100, 4, 11, 2602, 36])
Test2
findOutlier([2, 4, 0, 100, 4, 11, 2602, 36])