index.tsx231 chars11 lines
In the above code block, we have initialized two variables n
and arr
. n
specifies the size of the array and arr
is an empty array which we need to fill with numbers.
Then we have used a for
loop to iterate from 1 to n
and at each iteration, we have pushed the current loop counter value to the arr
using push()
method.
Finally, we have printed the resultant array using console.log()
method.
gistlibby LogSnag