function booo(n) {
for (let i = 0; i < n; i++){
console.log('booo!!');
}
}
booo(5); // O(1) <-- SPACE COMPLEXITY
function arrayofHiNtimes(n){
let hiArray = [];
for (let i = 0; i < n; i++){
hiArray[i] = 'hi';
}
return hiArray;
}
arrayofHiNtimes(6); // O(n) <-- SPACE COMPLEXITY
// find 1st, find Nth
const array = [
{tweet: 'hi',
date: 2012},
{tweet:'my',
date: 2014},
{tweet: 'teddy',
date: 2018}
];
// O(n^2) <-- SPACE COMPLEXITY
// array[0]; // O(1)
// array[array.length - 1]; // O(1)