Im very much a javscript beginner and have gone through books and online forums such as this one but can't figure this out.
I have an array that is
var n=[1,1,1,1,5,5,5,5];
What the elements/numbers are are the number of times a ball wil bounce. so at n[0] to n[3] the ball will bounce once, and n[4] to n[7] it will bounce 5 times.
I want to write this logic, but am not sure how...
I started with
var x = n[];
n = 0;
while (x < 3, x++) {
n = n[0];
n[]++;
}
for (x = 3) {
x++;
n = 1;
n[]++;
}
while (x > 3) {
n = 5;
}
But I Know that this is incorrect. I am not sure how to proceed with this, could someone pelase help me?
Thank you!
forand ofwhile?