You might get a cut in exercise to implement the range.
What does it have a mean?
It is a helper function, which looks like this.
For example, if we are calling the range from one to 50, it will generate force energy one two, three
four, five six and so on until 15.
And this is actually a really nice helper when you need to generate some data, for example, you want
to generate 50 random users.
In this case, you simply generate such array and then for every single element you mapping in your
random user.
This is why this helper exists in almost all helper libraries like, for example, a dash or render.
And obviously the easiest solution without thinking here is by using for loop, this is where you can
ride this function like this, you have a function range and you have here start and end, for example,
from one to 50 and then inside, we must try to follow up from start point to the end point.
This is why here let I equals time.
So we're not starting from zero, but from start here we're right and I less or equal end.
And here we are making A-plus plus now inside this four loop, we must push every single index to our
result.
This is body.
Let's create our let result.
This is our array.
Now inside, we can write results, push and we're pushing here our eye, and now we just return our
result.
This is how you can build the range function by using for Loop Let's Chicken Browser.
I am right in here range function one comma 50 and we're getting our array from one to 50, which means
our code is completely fine, but it is super low level and we can make it better.
More advanced level is to leverage our rate so we can write in browser array and then our end, for
example.
50.
And as you can see, this returns fast AMP territory where we have reserved 50 elements and what we
can write after this dot keys.
And now we are just calling this keys and we get an array iterate.
Now, if we will try to spread this reiterate inside array, as you can see, we're getting our 50 keys
starting from zero to 49.
And after this, we simply need to map every single element and add our start point to it.
So here we can write that map.
And here we have every single element and where right?
And Element plus tard in our case, for example, +1 and we're getting exactly the same outcome.
This is an array from one to 50.
This is why this variant is a little bit more advanced.
So here we can create our range function and we're getting here, start and end.
And now inside, we want to return this logic.
And as you can see, this is an array where we are provided and we're making keys and we're spread in
this array traitor inside our own USA and we're in every single element and we're adding here our start
point.
Let's reload the page and check if it's working.
So I'm passing inside our range function one and 50, and we're getting a nice array from one to 15.
And this is how people typically write this function inside help libraries.
For example, Lambda Olivet.