I have a maximum of quantity on a value and i want to see all the number on my dropdown
for exemple my quantity is
const quantity= 10
i want to create a function which pushed [1,2,3,4,5,6,7,8,9,10] on an array.
I'm working with react native
I have a maximum of quantity on a value and i want to see all the number on my dropdown
for exemple my quantity is
const quantity= 10
i want to create a function which pushed [1,2,3,4,5,6,7,8,9,10] on an array.
I'm working with react native
const arr = Array.from({ length: 10 }, (_, i) => i + 1);
console.log(arr);
This will help you
function createArray(len){
let arr = []
for(let i = 0 ; i < len;i++){
arr.push(i + 1);
}
return arr
}
let qty = 10
console.log(createArray(qty))