[javascript] Why do we need to use flatMap?