Giter VIP home page Giter VIP logo

promises-workshop's Introduction

Promises Workshop

We promise it won't hurt (too much)

Basic instructions

  • Fork this repository and create a new Cloud9 project by cloning your fork
  • Each exercise should be done in a separate branch, branched off of master, with a descriptive name of your choice
  • Completed exercises should be submitted as pull requests. The pull request name should be "Exercise #: " followed by the exercise's title
  • All the exercises require the bluebird NPM package. A package.json file is already initialized in this repo with this dependency. You'll have to do an npm install upon cloning in order to get all the dependencies.
  • Different exercises may also require different NPM packages. This will require you to use npm install --save to get these packages. The package.json should be part of the same commit where you start using the required package(s). For example, if one of the exercises requires the use of the request library, then the package.json for that submission should contain the dependency, and it should be committed at the same time as the exercise-#.js that requires it.

Exercise 1: Getting started!

  • Create a function called delay that takes a number of milliseconds, and returns a Promise that will be resolved with no value after the requested delay has passed.
  • Use your delay function to print messages "ONE", "TWO", "THREE", "...LIFTOFF!" to the console with a 1 second delay between each message
  • Hint: your delay function will use new Promise to create a Promise

Exercise 2

  • Create a function called getFirstChar that takes a string, and returns a Promise that will be resolved with the first character of the passed string, after 500 milliseconds. You may use the delay function from the previous exercise.
  • Create a function called getLastChar that takes a string, and returns a Promise that will be resolved with the last character of the passed string, after 500 milliseconds. You may use the delay function from the previous exercise.
  • Create a function called getFirstAndLastCharSeq that takes a string, and returns a Promise that will be resolved with the first and last character of the passed string. This function should use getFirstChar and getLastChar in sequence.
  • Create a function called getFirstAndLastCharParallel that takes a string, and returns a Promise that will be resolved with the first and last character of the passed string. This function should use getFirstChar and getLastChar in parallel, using the Promise.join functionality of the Bluebird library.

Exercise 3

After promisifying the request and prompt libraries, rewrite the "ISS Augmented" exercise using Promises!

Exercise 4

Create a program that will do the following, using Promises:

  • Prompt the user for an english word of their choice
  • Using Big Huge Thesaurus, go fetch the synonyms for the entered word
  • Display the synonyms of that word to the user in a nice way
  • For brownie points, use the colors library to get some colors in there!

Exercise 5

Create a program that will do the following, using Promises:

  • Read the WordNik API Documentation, especially the "words" section
  • Retrieve a list of 5 random words
  • Using the Big Huge Thesaurus API, go fetch synonyms for each of these words
  • Display the synonyms for each word to the user in a nice way
  • For brownie points, use the colors library to get some colors in there!

Exercise 6

Create a program that will do the following, using Promises:

  • Read the WordNik API Documentation, especially the "words" section
  • Retrieve a list of 2 random nouns, 2 random verbs and 2 random adjectives
  • Using the Big Huge Thesaurus API, go fetch synonyms for each of these words
  • Display the synonyms for each word to the user in a nice way, using Automattic's cli-table module
  • For brownie points, use the colors library to get some colors in there!

Exercise 7

  • Register for a forecast.io developer account to get an API key, and read the docs!
  • Prompt the user for their location
  • Using Google's Geolocation API, retrieve the latitude and longitude of the input location
  • Using forecast.io, retrieve the current forecast (for the next week) of the provided location
  • Display this to the user in a nice way using Automattic's cli-table module
  • For brownie points, use some weather emojis in your output :)

Challenge!!

  • Read the documentation about Bluebird's .map method
  • Using the map method, write a function that takes an array of city names, and returns a Promise for an array of {latitude, longitude} objects

promises-workshop's People

Contributors

ziad-saab avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.