const nemo = ['nemo'];
const everyone = [
'dory',
'bruce',
'marlin',
'nemo',
'gill',
'bloat',
'nigel',
'squirt',
'darla',
'hank',
];
const large = new Array(200).fill('nemo');
function findNemo(array) {
let t0 = performance.now();
for (let i = 0; i < array.length; i++) {
console.log('running');
if (array[i] === 'nemo') {
console.log('Found Nemo!');
break;
}
}
let t1 = performance.now();
console.log('Call to find Nemo took ' + (t1 - t0) + ' milliseconds');
}
findNemo(everyone); // O(n) --> Linear Time - Operation (number of inputs) in our example n is 10