Given a multidimensional array

var links = [ ['home', 'http://itstep.zp.ua'], ['contacts', 'https://itstep.zp.ua/contacts/'], ['news', 'https://itstep.zp.ua/news/'], ['success', 'http://success.itstep.org/'], ]; 

Closed due to the fact that the essence of the question is not clear by the participants Alex , 0xdb , Modus , user192664, yolosora Nov 19 '18 at 6:05 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Give an example of the desired result - Alex
  • just need to make a menu - Vetal Dudin Nov.
  • yes it works, tell me please, but can you write a simpler code, through document.write? I just started learning JS - Vetal Dudin
  • if with document.write , you can do it like pastebin.com/MUYndfYN - Alex
  • one
    Thank you very much! - Vetal Dudin 8:01

1 answer 1

 var links = [ ['home', 'http://itstep.zp.ua'], ['contacts', 'https://itstep.zp.ua/contacts/'], ['news', 'https://itstep.zp.ua/news/'], ['success', 'http://success.itstep.org/'], ]; let nav = ''; links.forEach(function(v){ nav += '<a class="nav-link" href="' + v[1] + '">' + v[0] + '</a>'; }); document.querySelector(".nav").innerHTML = nav; 
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/> <nav class="nav"></nav>