+ 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) + "]");

5th Jan 2018, 11:20 AM
Szabolcs Pongrácz
Szabolcs Pongrácz - avatar
2 Respostas
+ 5
Use == in your if-statement instead of =. == compares to values. = assigns a value.
5th Jan 2018, 11:52 AM
The Coding Sloth
The Coding Sloth - avatar
+ 1
Thank You. Yeah. It was the problem. :)
5th Jan 2018, 12:15 PM
Szabolcs Pongrácz
Szabolcs Pongrácz - avatar