Node.js beyond the basics quiz

Test your knowledge path progress

Comments

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.


Downloadable resources


Related topic

  • 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.

Comments

Sign in or register to add and subscribe to comments.

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