I m trying to iterate an array to find if a property matches some condition and retrieve the indexes where the condition applies and thought of using jquerys map method. After finding the exact solution to my problem here and the same problem ,I rolled my coffeescript in order to make things happen.
My object is this :
newWaypoint = {waypoint:latlon.toString(), legStart:leg.start_location.toString() ,legNumber:legNo.toString()}
and such objects are pushed in a simple array : @newDraggableWaypoints.push newWaypoint
This is the code thats giving me headeache:
buildNewWaypointsFromDraggable:()->
item=@allLegWaypoints[0]
indexes = $.map(@newDraggableWaypoints, (obj, index) =>
index if obj.legStart is item
)
window.alert indexes.toString()
Why is this message presented ? Thank you