Easy way to range -> array and array -> range? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Easy way to range -> array and array -> range?

I'm doing some tests on get range information and set it to an array's content to use it through different functions. Also, I'm looking to easy way to convert the content of an array into a range. My question is because is tricky to know how to write it, Maybe an array is 1-dimensional and a range is 2-dimensional? There's something I can't understand clearly on this, thanks!

10th Jul 2017, 9:56 PM
Aarón Fortuño Ramos
Aarón Fortuño Ramos - avatar
2 Answers
+ 1
// do you want to generate a range of values in an array ? var aSequence = [...Array(10).keys()]; console.log(aSequence); // construct a sequential array num to num var bSequence = [...Array(10).keys()].slice(4); console.log(bSequence);
11th Jul 2017, 4:36 AM
richard
+ 1
Thanks, I'll try!
11th Jul 2017, 5:16 AM
Aarón Fortuño Ramos
Aarón Fortuño Ramos - avatar