Reading notes for class 1 of 401

the Array.map() method creates an array by calling a specific function on every element of the array. Generally it is used to iterate over an array.

the Array.reduce() method iterates over the array and invokes the callback on each element. However it will only return whatever the final invocation of the callback returns.

const superagent = require('superagent');
function getDat() {
  superagent.get('http://colormind.io/list')
  .then(data => {
    console.log({
      [data.body] : data.body.url
    });
  })
  .catch(error => {
    console.log(error);
  })
}
getDat();

const superagent = require('superagent');
async function getCityData(city) {
  try {
    let cityInfo = await superagent.get(`https://geocode.xyz/${city}?json=1`);
  } catch(error) {
      console.log('error while retrieving cityData');
  }
}
getCityData('berkeley');

A promise is an object that represents the outcome of an async operation. A promise has three states: pending, rejected, or fulfilled.

Callback functions are not async functions by nature.