0

I have two arrays

array1=[1,2,3]

array2=['one','two','three']

I want the result to be

res=[[1,'one'],[2,'two'],[3,'three']]

[end of problem] The below line was added just to meet the question posting rules:

I tried looking it up online but did not find anything, I can do it in python,but still a beginner in javascript

0

1 Answer 1

2

you can use array.map ... one of many ways though :)

const array1=[1,2,3]

const array2=['one','two','three']

const res = array1.map((el,idx)=> [el,array2[idx]])

console.log(res)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.