+ 9

Java challenge question explanations

Forum for explanation of answers for Java challenge questions.

31st Jan 2017, 5:29 PM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
3 Respostas
+ 14
thank you
5th Mar 2017, 3:20 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
+ 9
What is the output of this code? 1 var arr = [1] //declare an array with 1 element 2 for (var i = 1; i < 3; i++) { //a "for" loop containing 1 and 2 3 arr [i] = arr [i-1] + i; //what? I don't understand this line 4 } 5 document.write(arr.join("")); //concatenation, needs explanation answer is 1 3 i think If someone could explain what is happening here I would be grateful, thank you
31st Jan 2017, 6:20 PM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar