const nemo = ['nemo']
const findNemo = (n) => {
// let t0 = performance.now();
for (let i = 0; i < n.length; i++){
if (n[i] === 'nemo') {
console.log("we found NEMO!!")
} else {
console.log('nope, not nemo...')
}
}
// let t1 = performance.now();
// console.log('Call to find Nemo took ' + (t1-t0))
}
findNemo(nemo)
function findNemo1(array) {
for (let i = 0; i < array.length; i++) {
if (array[i] === 'nemo') {
console.log('Found NEMO!');
}
}
}
findNemo1(nemo);
//#1 -- For loop in Javascript.
const fish = ['dory', 'bruce', 'marlin', 'nemo'];
const everyone = ['dory', 'bruce', 'marlin', 'nemo', 'gill', 'bloat', 'nigel', 'squirt', 'darla', 'hank'];
const large = new Array(10).fill('nemo');
function findNemo2(fish) {
let t0 = performance.now();
for (let i = 0; i < fish.length; i++) {
if (fish[i] === 'nemo') {
console.log('Found NEMO!');
}
}
let t1 = performance.now();
console.log("Call to find Nemo took " + (t1 - t0) + " milliseconds.");
}
findNemo2(everyone)