Node.js beyond the basics quiz

Test your knowledge path progress

Test your Node.js knowledge and skills and you'll be able to quickly assess how well you've mastered key information and coding techniques you've learned from this knowledge path.

Andrew Glover, CTO, App47

Andrew GloverAndrew Glover is a developer, author, speaker, and entrepreneur with a passion for behavior-driven development, Continuous Integration, and Agile software development. He is the founder of the easyb Behavior-Driven Development (BDD) framework and is the co-author of three books: Continuous Integration, Groovy in Action, and Java Testing Patterns. You can keep up with him at his blog and by following him on Twitter.



26 June 2012

Also available in Chinese Japanese Portuguese

These exercises and solutions supplement the developerWorks knowledge path "Node.js beyond the basics."

  1. Convert this simple node web application into Coffeescript:
    var express = require('express');
    
    var app = express.createServer(express.logger());
    
    app.get('/', function(req, res) {
      res.send("Hello World!");
    });
    
    var port = process.env.PORT || 3000;
    
    app.listen(port, function() {
      console.log("listening on " + port);
    });
  2. You inherited some code, written in Coffeescript, but it doesn't compile. Fix it:
    express = require 'express'
    
    app = express.createServer(express.logger());
    
    app.get '/', (req, res) ->
    	console.log "/ hit!"
    		res.send "Hello World!"
    
    var port = process.env.PORT || 3000
    
    app.listen port, ->
    	  console.log "listening on #{port}"
  3. Amazon's DynamoDB only supports string data types:
    1. True
    2. False
  4. DynamoDB supports indexing many different keys in a table:
    1. True
    2. False
  5. Why won't this Node program run? What's wrong with it?
    var express = require('express');
    
    var app = express.createServer(express.logger());
    
    app.get('/', function(req, res) {
      res.send("Hello World!");
    });
    
    var port = process.env.PORT || 3000;
    
    app.listen(port, function() {
      console.log("listening on #{port}");
    });
  6. Cake is:
    1. CoffeeScript's build tool
    2. Node library for working with DynamoDB
    3. Language inspired by Fortran that makes working with JavaScript easier
  7. Deploying your code to Heroku is done via:
    1. SCP
    2. FTP
    3. Git push
    4. Custom protocol
  8. DynamoDB's Scan API allows you to:
    1. Search on non-primary key fields
    2. Bulk upload images
    3. Create new Attributes in an Item
  9. With the Mocha testing framework, you can test both synchronous and asynchronous code:
    1. True
    2. False
  10. You can speed up a web app hosted on Heroku by adding more Dynos:
    1. True
    2. False
  11. What's wrong with the logic in this Mocha test written in CoffeeScript? Why does this test fail?
    describe 'updates for a beer using DynamoDB API', ->
    	before (done) ->
    		update = {votes: {put : 1}, type: {put: 'IPA'}}
    		dynode.updateItem 'beer_ratings', '60 Minute IPA', update, (err, resp) ->
    			done(err)
    	it 'should support incrementing a value corresponding to a vote', (done) ->
    		dynode.getItem 'beer_ratings', '60 Minute IPA', (err, item, meta) ->
    			item.should.have.property 'votes'
    			item.votes.should.be.above 1
    			done(err)
    	after ->
    		update = {votes: {add : 1}, type : {put: 'IPA'}}
    		dynode.updateItem 'beer_ratings', '60 Minute IPA', update, (err, resp) ->

Answers

Check your answers here.

Resources

  • Node.js beyond the basics: This knowledge path starts with Node.js basics and takes you beyond them to using Node and supporting technologies to build an application, test it, and deploy it on a platform-as-a service.
  • developerWorks Java technology zone: Find hundreds of articles about every aspect of Java programming.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Java technology on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=822168
ArticleTitle=Node.js beyond the basics quiz
publish-date=06262012