I am trying to loop through an object literal and map the substring to a value and plug it into an equation. Right now my code doesn't return an integer but instead is undefined. Here is the code:
function calcFunc(sequence) {
var dH = 0;
var dS = 108;
var i;
// Compute dH and dS
for ( i = 0 ; i < ( sequence.length - 1 ) ; i++ ) {
var pair = sequence.substr(i, 2);
dH += nn_h[pair];
dS += nn_s[pair];
}
dH *= -100.0;
dS *= -0.1;
return dH / ( dS + 1.987 * Math.log( 100 / 4000000000.0 ) ) - 273.15 +
16.6 * ( Math.log( 50 / 1000.0 ) / Math.log(10) );
}
/ log(10)should be/ Math.log(10)?sequencelooks like, could it be that you should increaseiby 2 in your loop?