Javascript: Find Last Element in Array