Javascript Array Count Elements In A Vector Quantity For It Has Both Magnitude