Quick actions

cmd+k|ctrl+k

Navigation

Languages

1st Big O

Snippet info

Language

JavaScript

Visibility

public

Author

patrykstachowiak

Created

2025-02-25T20:46:58.628236Z

Updated

2025-02-25T20:48:37.200233Z

const nemo = ['Ryan'];
const everyone = ['Bruce', 'David', 'James', 'Matt', 'Joe', 'Alan', 'Chris', 'Ryan', 'Paul', 'Nick'];
const large = new Array(10000000).fill('Ryan');

function findRyan(array) {
    let t0 = performance.now();
    for (let i = 0; i < array.length; i++) {
        if (array[i] === 'nemo') {
            console.log('Found Ryan!');
        }
    }
    let t1 = performance.now();
    console.log('Call to find Ryan took ' + (t1-t0) + ' miliseconds');
}

findRyan(large);
INFO