var express = require('express');
_ = require('underscore')._
var request = require('request');
var router = express.Router({mergeParams: true});
var exec = require('child_process').exec;
var path = require('path');
var parentDir = path.resolve(process.cwd());


router.get('/', function(req, res, next) {
    res.json({'info' : 'This is the ControCurator API v0.1'});
});

router.post('/',function(req,res) {
    try {
        var input = JSON.parse(req);
    } catch (e) {
        res.json({'error':'Input was not valid JSON.'});
    }

    var amountofitems = input.length;
    var gooditems = 0;
    var baditems = 0;

    foreach (var currentitem in input)
    {
        if (!currentitem.hasOwnProperty('id') || !currentitem.hasOwnProperty('text'))
        {
            baditems++;
            continue;
        }
        gooditems++;
    }
    var controscore = Math.random();


    res.json({'controversy':controscore,'totalItems':amountofitems,'goodItems':gooditems,'badItems':baditems});

});
module.exports = router;

@@ -627,14 +627,57 @@
  for
-each (
+ (var i=0; i %3C amountofitems; i++)%0A    %7B%0A        
 var 
@@ -692,23 +692,19 @@
 tem 
-in
+=
  input
-)%0A    %7B
+%5Bi%5D;
 %0A   

Fix in loop