Help for a JavaScript exercise with for ... of and join () [closed]

-8

Given the following vector of objects:

var usuarios = [
  {
    nome: 'Diego',
    habilidades: ['Javascript', 'ReactJS', 'Redux']
  },
  {
    nome: 'Gabriel',
    habilidades: ['VueJS', 'Ruby on Rails', 'Elixir']
  }
];

Write a function that produces the following result:

O Diego possui as habilidades: Javascript, ReactJS, Redux
O Gabriel possui as habilidades: VueJS, Ruby on Rails, Elixir

Tip: To go through a vector you must use the for...of syntax and to join values from an array with a separator use join .

    
asked by anonymous 11.04.2018 / 17:05

1 answer

-1

A very simple option:

  var usuarios = [
  {
    nome: 'Diego',
    habilidades: ['Javascript', 'ReactJS', 'Redux']
  },
  {
    nome: 'Gabriel',
    habilidades: ['VueJS', 'Ruby on Rails', 'Elixir']
  }
];

for (var i = 0; i < usuarios.length; i++)
{
        alert("O " + usuarios[i].nome + " possui as habilidades: " + usuarios[i].habilidades.join(", "));
}

See working at link

    
11.04.2018 / 18:37