Permalink
Browse files

Optimized to GFM

  • Loading branch information...
1 parent f6b87f2 commit 0aec60ee7be525153d0729bd2bd6e6e099b3553f @pgte pgte committed Aug 10, 2012
Showing with 19 additions and 15 deletions.
  1. +19 −15 article.md
@@ -25,8 +25,10 @@ There you have it - an array containing any arguments you passed in. Notice the
Where everyday CLI arguments are concerned, you'll want to skip the first two. Now try this in `argv.js`:
- var myArgs = process.argv.slice(2);
- console.log('myArgs: ', myArgs);
+```javascript
+var myArgs = process.argv.slice(2);
+console.log('myArgs: ', myArgs);
+```
This yields:
@@ -35,19 +37,21 @@ This yields:
Now let's actually do something with the args:
- var myArgs = process.argv.slice(2);
- console.log('myArgs: ', myArgs);
-
- switch (myArgs[0]) {
- case 'insult':
- console.log(myArgs[1], 'smells quite badly.');
- break;
- case 'compliment':
- console.log(myArgs[1], 'is really cool.');
- break;
- default:
- console.log('Sorry, that is not something I know how to do.');
- }
+```javascript
+var myArgs = process.argv.slice(2);
+console.log('myArgs: ', myArgs);
+
+switch (myArgs[0]) {
+ case 'insult':
+ console.log(myArgs[1], 'smells quite badly.');
+ break;
+ case 'compliment':
+ console.log(myArgs[1], 'is really cool.');
+ break;
+ default:
+ console.log('Sorry, that is not something I know how to do.');
+}
+```
JS PRO TIP: Remember to `break` after each `case` - otherwise you'll run the next case too!

0 comments on commit 0aec60e

Please sign in to comment.