Q:

Define object in javascript

I write some script for sum 3 numbers with express and jade... 
on index.jade i have a 3 fields and submit button:
!!! 5
html
  head
    title Test
  body
    form(name='form1', method='post', action='')
      label(for='1')
      input#1(type='text', name='1')
      label(for='2')
      input#2(type='text', name='2')
      label(for='3')
      input#3(type='text', name='3')
      input(name='submit', type='button', value='submit') 
    span #{result}

and on serverside (js code- node.js) I have this code:
var express = require('express');
        app = express.createServer();

app.configure(function(){
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
});
app.use(express.bodyParser());
    app.get('/', function(req, res){
     res.render('index');
    });

    app.post('/', function(req, res){
      var i = req.param('1', null);
      var j = req.param('2', null);
      var k = req.param('3', null);
      var r = i+j+k;
      res.render('index', {result:r});

    });
app.listen(3010);

but every time I start the js file via node app.js I goy message that the object is not defined and some errors in jade file:
How to define object in app.js file?
error:
ReferenceError: C:\Users\PC\glowing-frost-5319/views/index.jade:14
    12. '      input#3(type=\'text', name='3')
'
    13. '      input(name=\'submit', type='button', value='submit') 
'
    14. '    #{result}'

result is not defined
    at Object.<anonymous> (eval at <anonym... etc.

Anybody can tell me how to define object result and how to show on index.jade page? 

A:

I think you need to pass result in the second parameter to the render method in your get route (just as you are already doing in the post route).
Try this:
app.get('/', function(req, res){
    res.render('index', {result: ''});
});

This will make the result variable available in your view (with a value of empty string in this example).

