View on GitHub

reading-notes

Learning Notes Repo for Code Fellows

Node Ecosystem, TDD, CI/CD

  1. Describe (in plain English) what Array.map() does

    • this will go through all the elements in the array and calls the given function for each in order
  2. Describe (in plain English) what Array.reduce() does

    • it will execute a reducer function for each value in an array and return a single accumulated result of the given function
  3. Provide code snippets showing how to use superagent() to fetch data from a URL and log the result

    • With normal Promise .then() syntax

      superagent.get('path to api') 
        .then( data => {
          console.log(data.body);
          })
        .catch(err => console.error(err));
      
    • Again with async / await syntax

      async function getCity(city) { 
        let response = await superagent(`https://geocode.xyz/${city}?json=1`); 
        console.log(`${city}'s latitude is ${response.body.latt} and longitude is ${response.body.longt}`); 
      } 
      getCity('seattle');
      
  4. Explain promises as though you were mentoring a Code 301 level student

    • promises represent processes that are already happening in the background and will return you the result once finished. this will prevent any blockage of running other codes.
  5. Are all callback functions considered to be Asynchronous? Why or Why Not?

    • Callback functions are not asynchronous by default. They are depended on the nature of the higher order functions.

<==Back