How do I fill elements of an array on another array with respecting the size Example
Arra1 = ["1","2","3","4","5"]
Arra2 = ["R","B"]
result = ["R","B","R","B","R"]
How can I achieve that
How do I fill elements of an array on another array with respecting the size Example
Arra1 = ["1","2","3","4","5"]
Arra2 = ["R","B"]
result = ["R","B","R","B","R"]
How can I achieve that
You could do Array.map() with modulo %:
let Arra1 = ["1","2","3","4","5"]
let Arra2 = ["R","B"]
console.log(Arra1.map((num, ind)=>Arra2[ind%Arra2.length]))
//["R","B","R","B","R"]