[javascript] Why does javascript map function return undefined?