Functional Programming

What do functional programming languages have in common?

  • Separates the transforms of data from the data itself
  • functions take data and then decide what to do with it
  • separation between data transforms and the actual data itself is good because you don’t know what data you have / will have. you don’t need to modify the definitions. Easier to write correct programs.
  • Adds transparency to code and shows how it works.

var vs let vs const


var have a function scope.

hoisting – bring any sort of declaration including named functions on the top most scop possible.

vars bring the scope to the first line of the function. This happens when var is declared not being assigned. That is why you will get undefined instead of error


uses block scope.

only used in whatever is being declared aka the block scope.

hoisting doesnt exist with let.


scope – block scope like let.

Sethy really like your illustrations and the article overall. But I believe Functions are actually Vars is wrong.

It might seem they are the same, but there are some minor details which are easy to overlook.
In your example

function whatUp(){
console.log('what up');


var whatUp = function(){
console.log('what up');

are not the same thing, if you just move the whatUp to the top.

var whatUp = function(){
console.log('what up');

will fail whereas the one below won’t fail

function whatUp(){
console.log('what up');

This happens because in javascript functions are hoisted. But it doesn’t happen for anonymous functions.

var whatUp = function(){
console.log('what up');

The example above is called an anonymous function (since it doesn’t have a name), assigned to a variable whatUp. Anonymous functions are great for places where you quickly want to pass a function which doesn’t really need a name, for eg. callbacks. But they are difficult to debug, because if they throw an error, stack trace would look something like this.

But if we use a non-anonymous function it will also give us the helpful function name.

Data Structure into: CPU Memory and RAM

        Data Structures 
        - have value 
        - can have relationships amongst them
        - useful for its own thing
        - better algorithms for the data strctures 
        - tonne of data structures 
        - always trade off between readability/ memory (Space) / speed (Time)
        Memory in a computer

        Variables are stored in RAM (Random Acess Memory) - files are lost when computer turns off
        Storage stores files like music files which do not delete when the computer turns off
        CPU - speed. Accesses the RAM quicker than it accesses the storage

        Massive storage tables 
        has addresses or shelves 
        each address or shelf has 8 bits 
        8 bits = 1 byte 
        CPU is connected to a memory controller 
                                    -which does the reading and writting of the RAM 
                                    - has connections to each shelf 
                                    - can access memory really fast because there are connections to each shelf
                                    - the closer the memory is to the CPU or to the other shelf the faster the CPU is 
                                    - CPU cache is a tiny memory within the CPU

        - if a language doesnt have a data structure to hold the data value, it can be made. 
        e.g there are some data structures in java that arent in javascript for example priority lists, 
        though they are not in javascript, they can still be made

        traversal - going through each data value once

Big O Day 2 Notes

The difference between big oh, big omega and big theta notations?

- They are all asymptotic analysis - how much time a programme will take to perform an algorithm with regards to the amount of increased input
- asymptotes are lines that a given curve approaches or never touches 
- y-axis = running time 
- x-axis = input size 
- upperbound = big oh
                - worst case performance
- lowerbound = big omega
                - best case performance
- both upper and lower/ a tight bound = big theta
                - more meaning 
                - what people refer to in interviews 
                - closest to what will be performed 

// What is the Big O of the below function? (Hint, you may want to go line by line)
function funChallenge(input) {
  let a = 10; //o(1)
  a = 50 + 3;//o(1)

  for (let i = 0; i < input.length; i++) { //o(n)
    anotherFunction(); //o(n)
    let stranger = true; //o(n)
    a++; //o(n)
  return a; //o(1)

//BIG O(3 + 4n) simplifies to O(n)

for every step within a loop will run o(n)

// What is the Big O of the below function? (Hint, you may want to go line by line)
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)
    let y = i + 2;//o(n)
    let z = i + 3;//O(n)
for (let j = 0; j < input; j++) {
    let p = j * 2;//o(n)
    let q = j * 2;//o(n)
let whoAmI = "I don't know";//o(1)

//o(1+1+1+1) =o(4)
//o(4+5n)     simplifies to O(n)  

The 4 Rules for Big O
        1. Worst Case 
        2. Remove Constants 
        3. Different terms for inputs
        4. Dop non-dominants

1. Worst Case
    - if nemo is at the end  of the array (best case would be nemo being at the beginning of the array). Use a 'break' to make the code more efficient. 
    - Big O doesnt care about best case or medium, it cares about the worst case scenario.

2. Remove Constants
    - if the BIG O is O(1+ n/2 + 100) you need to drop the constants e.g make each part of the BIG O to the smallest whole number 
    - O(1 + n/2 + 100) become O(n+1) this can be taken one step further
    - O(n+1) becomes O(n) this is because the 1 is very insignificant if the actual number for one is very high e.g O(n+999999999999999999999999999) makes 1 seem very insignificant therefore 1 just get dropped 
    - O(n) is the final outcome

    - if the big o is O(4567238423n +123718974939853) this still drops down to O(n)
    - the constants on the n also are dropped to derive at O(n)

3. Different terms for inputs
    - if you have parameters in the function the different input parameters are classified as different letters from n 
    - function compressBoxesTwices(boxes, boxes2){


    BIG O(a+b)
    a = boxes
    b = boxes2

const food = ['apple', 'banana', 'carrot', 'dragon fruit', 'eggplant'];

function addNumberToFruitItems(array){
    for(let i = 0; i < food.length; i++){
        for(let j = 0; j< array.length; j++){
            console.log(food[i], food[j])


- if there are nest loops this means the n multiples by the other n 
- this gives a big o of O(n *n) which simplifies to O(n^2)
- O(n^2) is classified as horrible on the BIG o complexity scalable

- any step that happens in the same indentation e.g one after the other see below 
- below shows steps that happen one after the other 
- with steps that happen one after the other the different letters for n are added O(a +b) 

    function compressBoxesTwice(boxes, boxes2){             //FIRST LOT

        boxes.forEach(function(boxes){                       //SECOND LOT

- for nested functions that happens within an indentation you times the different letters for n e.g O(a*b) see below for actual example

const food = ['apple', 'banana', 'carrot', 'dragon fruit', 'eggplant'];

function addNumberToFruitItems(array){
    for(let i = 0; i < food.length; i++){            //FIRST ROUND NESTING
        for(let j = 0; j< array.length; j++){        //SECOND ROUND NESTING
            console.log(food[i], food[j])


4. Dop non-dominants (drop non-dominant terms)

- if the big o is O(x^2+3x+100+x/2) the most significant terms is x^2 as when it scales it becomes much greater than any other part of the big o
- nested loops are classified as terrible. 

Big O 
    O(1) === O(0.5) === O(3) === O(8937498753) Constant -GOOD- no loops 
    O(n) === 0(0.5n) === O(3n) === O(8937498753n) Linear - FAIR - for loops while loops
    O(n^2) === 0(n^0.5) === O(n^3) === O(n^8937498753) Quadratic - HORRIBLE - every element in a collection needs to be compared to every other element. Two nested loops and more.
    O(a+b) = Two separate collections

    O(n!) = WORST BIG O OUTCOME POSSIBLE! AVOID AT ALL COSTS! = FACTORIAL = nested loop for every input we have

What is good code?

1. Readable
        - others can read it 
2. Scalable
        - Speed - CPU  - Time Complexity
        - Memory -RAM (Random access memory) - Space Complexity

Usually theres a trade off between time and Space


- Heap = Where we store variables we assign 
- Stack = Where we keep track of our function calls 

What causes space complexity?
        - variables
        - Data Structures 
        - Function calls
        - Allocations

    function boooo(n){
        for( let i=0; i < n.length; i++){
    boooo([1,2,3,4,5]) //O(1) space complexity

    function arrayOfHintTimes(n){
        let hiArray = [];
        for(let i = 0; i < n.length; i++){
            hiArray[i] = 'hi';
        return hiArray;


        - uses different Big O space complexity depending on what language it is written in. 
        - some languages it iterates over every letter in the string and other languages it iterate the string in one go 
        - you should learn how the methods approach the syntax depending on the language 



  • If a telephone number is shown in SQL it is classified as text as it begins with a 0.
  • CHAR = fixed length string e.g product code number
  • VARCHAR = variable length string e.g name
  • FlOAT(P) = approximation of the number youve asked for within a given precision
  • binary = fixed- length strings max 255 characters
  • decimal(m,d) = fixed point number where m is the total digits and d is the number of digits after the decimal
  • boolean = data type where a value of 0 is considered to be FALSE and any other value is considered true!
  • null = lack of value

SELECT column_name FROM table_name;

create database – the whole data

describe – only use a part of the database and you cant get out of it


SQL and MySQL starter guide

What is a Database?

  • collection of data
  • has an accessible interface

What is the difference between a database and a database management system?

A database is like a file that has many piece of information on it.

A database management system allows interaction with databases.

MySQL = a database management system



database management system that uses SQL


  • Structured query language
  • how we talk to the database
  • the language used for talking to data
  • find all users
  • add new user
  • delete new user

english: find all users who are 18 or older

SQL: SELECT * FROM Users Where Age >= 18;

How to create a database on MySQL:

Start the CLI:

mysql-ctl cli; 

List available databases:

show databases; 

The general command for creating a database:

CREATE DATABASE database_name; 

A specific example:

CREATE DATABASE soap_store; 

To drop a database:

DROP DATABASE database_name; 

For Example:

DROP DATABASE hello_world_db; 

Remember to be careful with this command! Once you drop a database, it’s gone!

Beginning the quest to understanding the Big O

        /*Big O asymptotic analysis 
        - tells us how well a problem is solved
        - measures scalability of code 
        - how long an algorithm takes to fine

// const nemo = ['nemo'];
// const everyone = ['dory', 'bruce', 'marlin', 'nemo', 'gill', 'bloat', 'nigel', 'squirt', 'darla', 'hank'];
// const large = new Array(100).fill('nemo');
// const larger = new Array(1000).fill('nemo');
// const largest = new Array(1000000).fill('nemo');

// function findNemo(array){
//     let t0 =;
//     for(let i = 0; i< array.length; i++){
//         if(array[i]==='nemo'){
//             console.log('Found Nemo');
//         }
//     }
//     let t1 =;
//     console.log('call to find Nemo took ' + (t1 - t0) + ' milliseconds');
// }

// findNemo(nemo);
// findNemo(everyone);
// findNemo(large);
// findNemo(larger);
// findNemo(largest);

Use the word '' times how long it takes if is put at the beggining and end. 
then calculate 
end   minus   beginning

Big O = How many steps it takes to execute a function

// const nemo = ['nemo'];
// const everyone = ['dory', 'bruce', 'marlin', 'meno', 'gill', 'bloat', 'nigel', 'squirt', 'darla', 'hank'];
// const large = new Array(100).fill('nemo');
// const larger = new Array(1000).fill('nemo');
// const largest = new Array(1000000).fill('nemo');

// function findNemo(array){
//     for(let i = 0; i< array.length; i++){
//         if(array[i]==='nemo'){
//             console.log('Found Nemo');
//         }
//     }
// }

// findNemo(large);

//O(n)   = linear time = as elements increase, operations increase at the same rate
// n = number of elements 
//O(n) = fair on the bad to good graph

//forEach loops do not need a given range; therefore, for each can be used for the Quiz adding a number before each question
function compressAllBoxes(boxes){

const compressAllBoxes = boxes => {
    boxes.forEach(box => console.log(box));


O(1) = Constant Time

function compressFirstBox(boxes){

^The above function always take the first item in the array 'boxes[0]' no matter how many items/ boxes there are in the array

with constant time the number of operations stays flat while the elements increase
// const boxes = [0,1,2,3,4,5];

// function logFirstTwoBoxes(boxes){
//     console.log(boxes[0]); //O(1)
//     console.log(boxes[1]); //O(1)
// }

// logFirstTwoBoxes(boxes) //O(2) operations 

// when the big O gives a flat line this is then rounded and called O(1) or constant time even it its O(2) or O(39) or O(9283402342) they are all rounded to O(1) as they are all constant time
//O(1) is in the dark green or 'excellent catagory on the complexity chart
//O(1) is very scalable as no matter how many elements we have it will always have the same amount of operations e.g it will always run the same

//first Big O challenge

function funChallenge(input){
    let a = 10; //Some people do not count assigment to big o but we are going to //o(1)
    a = 50 + 3; // O(1)

    for(let i=0; i < input.lenth; i++){ //O(length of input) // O(1)
        anotherFunction(); // O(n)
        let stranger = true;// O(n)
        a++; //O(n) 
    return a; // O(n)


/* How to solve the big O challenge:

1. Go line by line or step by step within the function noting down the O notation 

2. Bestide each stage write which type of o it is e.g O(n) or O(1) ect.

3. Count how many O(1)'s there are, how many n's there are ect. 

4. O(3 + n + n + n) = O(3+4n)

5. When this is simplified it is just O(n)


Quick Blog Notes for finding jobs in tech

- <- makes resume's online 
- add keywords, add personal e.g company names
- online links to where work is

- Things to make your resume good
                    - make resume fit onto one page 
                    - use keywords that were put into the job description 
                    - include company name youre applying to 
                    - does the first thing on the resume reflect what the company is looking for 
                    - experience title should demonstrate that you provided value
                    - <- tells you how your resume compares to a job description 
- Things to note if you do not have the experience required 
                    - git hub green dots 
                    - open source 
                    - zero to mastery open source projects 
                    - have own website 
                    - creative tim        / mash-up template   ==> template websites
                    - 1 to 2 Big Projects
                    - Blog
- Email 
                    -Hey $BOB,
                    I saw your presentation at $CONFERENCE last year on Youtube (rr point to some work they have done).
                    Great stuff; loved what you did with $FOO, in particular
                    I'm also a $FOO developer. I noticed that your company is hiring
                    or $ROLE. I’d love to be a part of your team. Do you have a
                    few minutes to chat on Thursday about what you guys are doing?
                    Your website or any public profile link
- Where to find jobs 
                    - hackernews 
                    - linkedin 
                    - angel list 
                    - we work remote     (remote working jobs)
                    - triple byte
                    - white truffle 
                    - hired 
                    -site: facebook recruiter 

- to follow along with code
                    -repl it
                    - glot io

Flexbox – The complete guide

flex container = The thing that contains all the items that will be used with flex on it

flex items = items that will move due to the flex

If a bag of skittles was a flex box item. The bag would be the flex container and the individual skittles would be the flex items.

When display: flex is put on a flex container, flex is available for all direct children of the container.

Create your website with
Get started