Friday 15 May 2015

arrays - Can't access Javascript variable: undefined -


I am trying to add 2 sine waves and add them together to make a third I add them properly I can send the result to the console, but whenever I try to put this value in an array, I get an error:

"undefined 'property' 1 ' Can not read

Can someone explain where I'm going wrong? Platform: Signature function for sample (i = 0; i & lt; 2 * Math.

  D1 = []; d2 = []; d3 = []; // sign function for sample PI; i + = 0.02) {d1.push ([i, 15 + Math, sin (5 * i)]; D2.push ([i, 10 + Math, sin (4 * i)]; Console. Log (d1 [i] [1] + d2 [i] [1]); d = d1 [i] [1] + d2 [i] [1]; console.log (d); d3 Push ([i, d]);    

dX DX [dX.length - 1] .

Your i is float here (0.02). Value is not an integer, it is applied in a string goes. Then the Array object is interpreted as a regular object (the type of a map). There is no main "0.02" in the object, therefore evaluates DX ["0.02"] by undefined . You can not access undefined , so for the error.

No comments:

Post a Comment