Beta

Object to Array

Description
Loading description...
Arrays
Algorithms
  • Please sign in or sign up to leave a comment.
  • farhanaditya Avatar

    JS: Node v14 should be used along with its appropiate assertion tools (Mocha + Chai). Refer to this and this

  • Voile Avatar

    It's an implicit guess as to what kind of keys would constitute as a number.

  • JohanWiltink Avatar

    About the You must not change the value given in input this is impicitly tested. If the user modifies the array, the test will fail, same for the object.

    Ehm, actually, no, that's not how it works.

  • JohanWiltink Avatar

    You must not change the value given in input.

    This is not tested.

    Also, the random tests somehow (all, both object and array!) accept undefined as a correct answer, and are vulnerable to input modification.

    • AzariasB Avatar

      About the You must not change the value given in input this is impicitly tested. If the user modifies the array, the test will fail, same for the object.

      The random test cases where accepting anythin since I was testing the user's function against itself ! Thanks for reporting, it's now fixed.

      Issue marked resolved by AzariasB 8 years ago
    • JohanWiltink Avatar

      I can see how that can happen .. :smile: good job on the quick fix!

  • docgunthrop Avatar

    It may be worth noting that since object keys are strings, a type conversion is needed to return an array with the Number value of a given key.

    Basically, the input object {'1':5} for objectToArray is expected to return an array[1,1,1,1,1], and not ['1','1','1','1','1'].

  • bitfragment Avatar

    Error in the instructions:

    objectToArray({2:5, 9:1}) => [2, 2, 2, 2, 2, 99]
    

    It should read:

    objectToArray({2:5, 9:1}) => [2, 2, 2, 2, 2, 9]
    
  • bitfragment Avatar

    An error in the test cases prevents a valid solution:

    var obj = {none:0, nada:0, rien: 0};
    Test.assertSimilar(objectToArray(arr),[]);
    

    It should read:

    var obj = {none:0, nada:0, rien: 0};
    Test.assertSimilar(objectToArray(obj),[]);