Jump to content

Create A Large Animation Array With Simple Pattern


oliversb
 Share

Recommended Posts

You could create a function to do this for you:

function arrayValues(start, end) {    var output = [];    if (start > end) {        for (var i = start; i >= end; i--) {          output.push(i);           }    }    else {        for (var j = start; j <= end; j++) {          output.push(j);           }            }    return output;}

 

Link to comment
Share on other sites

No unfortunately not, and seemingly most of the range functions people have posted online don't work in reverse, or do weird things when you use negative numbers - the example above is a little clunky in how it's written, but it handles these outside cases.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...