Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Map associado com concat[]
- const escola = [{
- nome:'Turma M1',
- alunos:[{
- nome:'Gustavo',
- nota:8.1
- },{
- nome:'Turma M2',
- alunos:[{
- nome:'Rebeca',
- nota:8.9
- }, {
- nome:'Roberto',
- nota:7.3
- }]
- }
- ]
- }]
- const getNotaDoAluno = aluno => aluno.nota
- const getNotasDaTurma = turma => turma.alunos.map(getNotaDoAluno)
- const notas1 = escola.map(getNotasDaTurma)
- console.log(notas1);
- console.log([].concat([8.1,8.3],8.9,7.3))
- Array.prototype.flatMap = function(callback){
- return Array.prototype.concat([], this.map(callback))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement