+ 1
Hy! Could you help me with that problem? I tought an aletrt box should appear.
var n = new Array(); var m = new Array(); n[0] = 1 n[1] = 2 m[0] = 2 m[1] = 2 m[2] = 6 document.write(n.length ); document.write(m.length + "<br />"); function add (a,b){ document.write(a.length ); document.write(b.length + "<br />"); if(a.length = b. length){ document.write(a.length ); document.write(b.length + "<br />"); var x = new Array(); for (i=0; i<a.length; i++) x[i] = a [i] + b [i] return x } else{ alert("not egal length"); } } document.write("The result is: [" + add(n,m) + "]");
2 Réponses
+ 5
Use == in your if-statement instead of =.
== compares to values.
= assigns a value.
+ 1
Thank You. Yeah. It was the problem. :)