34

Run Settings
LanguageJavaScript
Language Version
Run Command
// 28 // const nemo = ['nemo']; // const everyone = ['dory', 'bruce', 'marlin', 'nemo', 'gill', 'bloat', 'nigel', 'squirt', 'darla', 'hank']; // const large = new Array(1000).fill('nemo'); // function findNemo(array) { // let t0 = performance.now() // for (let i = 0; i < array.length; i++) { // if (array[i] === 'nemo') { // console.log('Found NEMO!') // } // } // let t1 = performance.now() // console.log('Call to find Nemo took ' + (t1-t0) + ' milliseconds') // } // findNemo(nemo); // findNemo(everyone); // findNemo(large); // 30 // const boxes = [0, 1, 2, 3, 4, 5]; // function logFirstTwoBoxes(boxes) { // console.log(boxes[0]); // console.log(boxes[1]); // } // logFirstTwoBoxes(boxes); // 32 // function funChallenge(input) { // let a = 10; // O(1) // a = 50 + 3; // O(1) // for (let i = 0; i < input.length; i++) { // anotherFunction(); // O(n=input) // let stranger = true; // O(n=input) // a++; // // O(n=input) // } // return a; // O(1) // } // // BIG O(3 + 3n) -> O(n) // 34 // function anotherFunChallenge(input) { // let a = 5; // O(1) // let b = 10; // O(1) // let c = 50; // O(1) // for (let i = 0; i < input; i++) { // let x = i + 1; // O(n=input) // let y = i + 2; // O(n=input) // let z = i + 3; // O(n=input) // } // for (let j = 0; j < input; j++) { // let p = j * 2; // O(n=input) // let q = j * 2; // O(n=input) // } // let whoAmI = "I don't know"; // O(1) // } // // BIG O(4 + 5n) -> O(n) // 39 // Log all pairs of array // const boxes = ['a', 'b', 'c', 'd', 'e']; // function logAllPairsOfArray(array) { // for (let i = 0; i < array.length; i ++) { // for (let j = 0; j < array.length; j++) { // console.log(array[i], array[j]); // } // } // } // logAllPairsOfArray(boxes); // Quadratic time // 40 // function printAllNumbersThenAllPairSums(numbers) { // console.log('these are the numbers:'); // numbers.forEach(function(number) { // console.log(number); // }); // console.log('and these are their sums:'); // numbers.forEach(function(firstNumber) { // numbers.forEach(function(secondNumber) { // console.log(firstNumber + secondNumber) // }); // }); // } // printAllNumbersThenAllPairSums([1, 2, 3, 4, 5]) // // O(n + n^2) -> O(n^2)
Editor Settings
Theme
Key bindings
Full width
Lines