Skip to content

Mentoria de revisão da turma 23 #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Desafios/Destructuring e HOFs/desafio-hofs-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ const data = require('./data');

/** 1 - Retorne e exiba um array com as informações da primeira e da segunda banda utilizando destructuring
*/
const getBandsInformation = () => {
// console.log(data.bands);

const getBandsInformation = ({ bands }) => {
const [ primeiraBanda, segundaBanda ] = bands; // estamos armazenando apenas as duas primeiras bandas do array
return [ primeiraBanda, segundaBanda ]; // criando um novo array contendo apenas as duas bandas
}

// para ver todos os objetos em detalhes, usar o JSON.stringify(objeto)
console.log(getBandsInformation(data));

module.exports = getBandsInformation;
23 changes: 22 additions & 1 deletion Desafios/Destructuring e HOFs/desafio-hofs-02.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ const data = require('./data');
retornando uma string no seguinte formato: "os melhores álbuns do Radiohead: In Rainbows,Kid A,OK Computer,Pablo Honey"
*/

const getBestAlbuns = () => {
const getBestAlbuns = (bands) => {
const [ primeiraBanda ] = bands;
const { bandName, bestAlbuns } = primeiraBanda;

const albumNames = bestAlbuns.map((bestAlbum) => {
return bestAlbum.name;
});

const stringAlbumNames = albumNames.join(',')

return `os melhores álbuns do ${bandName}: ${stringAlbumNames}`;
}

// const getBestAlbuns = ([ primeiraBanda ]) => {
// const { bandName, bestAlbuns } = primeiraBanda;

// const albumNames = bestAlbuns.map(({ name }) => name);

// const stringAlbumNames = albumNames.join(',')

// return `os melhores álbuns do ${bandName}: ${stringAlbumNames}`;
// }

console.log(getBestAlbuns(data.bands));


module.exports = getBestAlbuns;