learnyounode!
Gainesville JavaScript
July 8th, 2015
Frontend Developer @ 352 Inc.
me@eran.sh @EranSchoellhorn
?
Family Man
Chicken Farmer
Amatuer Professional Eater
An intro to Node.js via a set of self-guided workshops."
Go to nodejs.org, click Install, Install..
Open Terminal, enter
npm install -g learnyounode
Make a directory somewhere.
learnyounode
Go there.
Enter .
Use arrow keys to navigate, enter to select stuff.
Start with "HELLO WORLD"
Create a node script that prints "HELLO WORLD" to the console
$ node exercise1.js
HELLO WORLD
HELLO WORLD
Create a script that takes any number of numeric arguments
and prints their sum.
$ node exercise2.js 1 1 1
3
BABY STEPS
Create a script that prints the number of lines in a file.
Accept a filename as an argument.
$ node exercise3.js exercise1.js
1
MY FIRST I/O
Create a script that prints the number of lines in a file.
Accept a filename as an argument. Use Async this time, Pal.
$ node exercise4.js exercise1.js
1
MY FIRST ASYNC I/O
Create a script which lists all files in a given directory with a given extension.
$ node exercise5.js ~/Downloads zip
roboto.zip
pants.zip
FILTERED LS
Move logic from previous exercise into an external module. Include module in main script using require()..
$ node exercise6.js ~/Downloads zip
roboto.zip
pants.zip
MAKE IT MODULAR
Create a script that takes a URL as an argument. When run, the script should console.log the response of the provided URL.
$ node exercise7.js http://randomword.setgetgo.com/get.php
gutturalism
HTTP CLIENT
Do the same thing as before but first print the number of characters in the response, then print the whole response.
$ node exercise8.js http://randomword.setgetgo.com/get.php
11
nonloving
HTTP COLLECT
Take 3 URLS, get all their responses and then print to
console in order they were provided.
$ node exercise8.js http://randomword.setgetgo.com/get.php ...
chiripa
bibliothecarial
tetrafolious
JUGGLING ASYNC