Link datas of arrays from a 2D array

Hello guys and girls,

I have a problem with my 2D array: I do not find how to link the datas of an array with the other one

Here is my my 2D array (with 2 arrays : days and names):

var tabJDayName = [

    ['monday', 'tuesday', 'wednesday','thursday','friday','saturday','sunday'],

    [franck, arthur, fred, fabrice, rené, bernadette, eric]


I would like the console to show me this :

monday: franck

tuesday: arthur

wednesday: fred

and so on…

My latest test is (it gives me the day and then the name but it doesn’t maake couples out of it):

            for(var i = 0; i<2; i++){




I also tried this (which gives me the arrays and then their content):

for(var i = 0; i<tabJDayName.length; i++){


          for(var j = 0 ; j<tabJDayName[i].length; j++){




If someone could help it would really be awesome for me !

The following does the job, where it loops through the days, and uses the index of the day to retrieve the persons name.

tabJDayName[0].forEach(function (day, index) {
    console.log(day + ": " + tabJDayName[1][index]);

Thank you Paul ! It works indeed, the “foreach” is a notion I don’t know yet, that is why I was trying with “for” loop. Have a nice day !

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.