Ad
  • Custom User Avatar

    how's this working without setting i as a parameter??

  • Custom User Avatar

    Even thought your solution would work the problem with this approach is the runtime complexity.
    Iterating over an object has a runtime of O(n), or more presice O(17) in this example since the number of languges is constant.
    The benefit of using a HashMap (object in JavaScript) is that you can lookup / retreive items in constant runtime O(1).
    Especially when dealing with large datasets this can cause siginificant performance differences.