Something is rotten with Array.map in javascript