Q:

Why does this code get undefined but not 2?

I try to translate this Scheme code to Javascript:
(define (double f)
  (lambda (x) (f (f x))))
(define (inc x) (+ x 1))
((double inc) 0)

((double inc) 0) means (inc (inc 0)), so it returns 2.
This is my Javascript code:
var double = function(f){
    return function(x) { f(f(x)); }
}
var inc = function(x) {return x+1;}
double(inc)(0);

But double(inc)(0) returns undefined, not 2. Why?

A:

var double = function(f){
    return function(x) { return f(f(x)); }
}
var inc = function(x) {return x+1;}
double(inc)(0);

Small mistake :) should work with the return.
If a function doesnt return anything, it actually returns undefined.
In your double function you have a function which returns "nothing" => you get undefined.

A:

You missed return in double function: 
    var double = function(f){
        return function(x) {return f(f(x)); }
    }
    var inc = function(x) {return x+1;}
    double(inc)(0);

