+ 9
Java challenge question explanations
Forum for explanation of answers for Java challenge questions.
3 Respostas
+ 14
thank you
+ 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