converting javascript map() to jquery map()