Sorry if the title is confusing.
I have an object called question, which contains a property called brokenUp. I also have a randomly generated number. Now, if the number had 3 digits, I would want the program to add something. For instance:
var arr = [400, 40, 2]; //really just 442 but broken up.
var n= arr.length;
Now the main problem is here:
question.brokenUp = arr[0] + arr[1] + arr[2];
How can I make this line above work for any value?
What if I had 4 digits? How can I make it so it does arr[0]... arr[4] by itself and so on?