1

Can anyone help me with this.

how do i convert this

var array_name = ["Name1", "Name2"];
var array_score = [8, 9];

into like this

var mydata = [ ["Name1", "Name2"],[8,9] ] 

I want my array_name and array score be joined together like the mydata array. Can anyone help me with this,? Thanks

3 Answers 3

6

var mydata = [array_name, array_score]

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

Comments

3

Hope this snippet will be useful

var array_name = ["Name1", "Name2"];
var array_score = [8, 9];

var mydata =[];

mydata.push(array_name,array_score);
console.log(mydata)

DEMO

Comments

0

Here is some examples :

var array_name  = ["Name1", "Name2"];
var array_score = [8, 9];

/*Example 1 :*/
var mydata = [];
mydata = [array_name,array_score];
console.log(mydata);

/*Example 2 :*/
var mydata = [];
mydata[0] = array_name;
mydata[1] = array_score;
console.log(mydata);

/*Example 3 :*/
var mydata = [];
mydata.push(array_name);     /*OR mydata.push(arr1,arr2,....);*/
mydata.push(array_score);
console.log(mydata);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.