I'm doing the Angular Tour of heroes tutorial, but there is somethings I don't understand, I did some google reasearch but I don't find out an explanation. I don't know where I could ask question. So, sorry if I am in the wrong place...
So, there : https://angular.io/tutorial/toh-pt6#simulate-a-data-server
I don't understand this part :
// Overrides the genId method to ensure that a hero always has an id.
// If the heroes array is empty,
// the method below returns the initial number (11).
// if the heroes array is not empty, the method below returns the highest
// hero id + 1.
genId(heroes: Hero[]): number {
return heroes.length > 0 ? Math.max(...heroes.map(hero => hero.id)) + 1 : 11;
}
the genId() method, what does it do ? Someone can explain me step by step please ?
especially this part :
return heroes.length > 0 ? Math.max(...heroes.map(hero => hero.id)) + 1 : 11;
this is the part where i get lose :
Math.max(...heroes.map(hero => hero.id)) + 1 : 11;
Thanks.