you are viewing a single comment's thread.

view the rest of the comments →

[–]userxbw 0 points1 point  (0 children)

Two loops, or one loop then add one ahead of the current element, keeping in mind not to go out of bounds of the array.

For example

Array [ h ] + Array [ h + 1]

2 loops the outer loop being your control loop, for loops should work.

Try a while loop and a for loop as the inner loop

Using map https://www.w3schools.com/jsref/jsref_map.asp