GithubHelp home page GithubHelp logo

node-walkthrough's Introduction

Node walkthrough

  1. In a new file called index.js write a CLI application that accepts a user parameter and logs it to the console.

  2. Push your result to a new GitHub repo called node-walkthrough and post the link to #exercises on Slack. We're going to do this after each exercise because fearlessness is built from backups. Here's a workflow that works for me:

    a) At the start of each exercise, checkout a new branch and commit working code at each step as you complete it.

    b) checkout master and merge your feature branch. push once you finish each one to help me keep an eye on progress as you go.

    c) Test that your code definitely works on master, then delete unused branches.

  3. In a new file called messaging.js write a new function called showHelp.

    a) This function should print help text to the console.

    b) Connect this function to index.js using CommonJS Module syntax. The function should fire if the term --help appears anywhere in the argument list. Think about your control flow before writing code.

    Remember: Git is your friend.

  4. In a new file called formatting.js write a new function called removeWhitespace. This function should take a string as a parameter and:

    a) Trim whitespace from the beginning and end of the param

    b) Collapse spaces (ensure only one space appears at a time, no doubles)

    Example output:

    • ' sao tome' => 'sao tome'
    • 'kuala lumpur ' => 'kuala lumpur'

Tip: Use console.log to check your output as you go. Remove any test calls to console.log once you're happy with the output.

Remember: Do the Git dance.

  1. Still in formatting.js write a new function called capitalizeInitial. This function should take a string as a parameter, and return it with only the first letter capitalized.

    Example output:

    • 'europe' => 'Europe'
    • 'BERLIN' => 'Berlin'
    • 'aSIa' => 'Asia'

Remember: Have you committed lately?

  1. Still in formatting.js write a new function called prepareString that puts an input string through capitalizeInitial and removeWhitespace then replaces any spaces with underscores.

    Example output:

    • 'kuala lumpur' => 'Kuala_Lumpur'
    • ' puerto rico' => 'Puerto_Rico'
    • ' tokyo' => 'Tokyo'

There are a million other ways we should sanitize user input before using it in a production app, but this will do for now.

Remember: Hmmm end of the exercise. Wasn't there something to remember...?

  1. Start a new file called client.js to handle your API call (similar to what we did yesterday).

Remember: Did you remember on your own this time?

  1. Write a function to format the API response before presenting it to the user, so it's easier to read. (To decide where to write this function, think about how your control flow will go through your files and functions between input and ouput).

Remember: What happens before the next exercise?

  1. Handle common errors with helpful messages for the user

Remember: You know the drill.

  1. Pick another endpoint to be handled by the same app. At which points will your existing control flow need to change to accommodate this? Go through the steps of preparing input, performing the call and formatting output. Keep committing as you complete small steps toward this.

node-walkthrough's People

Contributors

evalarumbe avatar

Forkers

bruhu

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.