Question

I have a code of about 70 odd lines.Just for testing purpose i want to check the output of what a function is returning. When I dumped my entire code in the console.log it did returned some array!!! But when I dump a particaular function from my code,it displays error. Is it possible to check the output of function in console.

Not necessary,but my fiddle---> http://jsfiddle.net/ddfsb/4/

I want to check what these 2 functions are returning-:

var getColumnCell = function (d, col)
{
    var arr = d[1], ret = null

    for( var  i in arr ) {
    ret = arr[i][0] == col ? arr[i] : ret;
    if (ret) break;
    }
    return ret;
}

var mapCell = function (row)
{
return columns.map(function(column) {
return { column : column, value : getColumnCell(row, column) }
})
}
Was it helpful?

Solution

I made an update to your script.

Please check out this new fiddle.

I am logging to console the return values of those functions.

In the getColumnCell function, I had to store the return value in a variable, and had to JSON.stringify the console output, as it was returning Object's.

The console output looks like this:

getColumnCell is returning parties,0,0.9 
getColumnCell is returning null 
getColumnCell is returning null 
getColumnCell is returning null 
getColumnCell is returning null 
getColumnCell is returning null
mapCell is returning [{"column":"parties","value":["parties",0,0.9]},{"column":"star-speak","value":null},{"column":"signature","value":null},{"column":"fashion","value":null},{"column":"live-responsibly","value":null},{"column":"indulge","value":null}] 

OTHER TIPS

Seeing as you are saying "getColumnCell" and "mapCell" are both equal to functions, try outputting both variables, instead of the raw functions themselves.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top