In a JavaScript object literal, why can’t a method access a sibling method just by its name?
12:40 22 Mar 2013

This code:

var doc = {
  foldPrompt: function(folded) {
    return folded ? "Click to unfold" : "Click to fold"
  },
  createFoldButtons: function() {
    var prompt = foldPrompt(true); //The error is here
    $("#ComparisonTable td.secrow").each(function(index, td){
      $(td).prepend($(''+prompt+''));
    });
  }
}

gives me an error: “Undefined variable: foldPrompt”

What am I doing wrong?

javascript