When transforming a collection into a hash map:

  {[dynamic_key]: 'bonjour', lang: 'fr'},
  {[dynamic_key]: 'hello', lang: 'en'},

to this:

  dynamic_key: 'fr',
  dynamic_key: 'en',

Would the method to do this be considered n^3 or 3*n?

(data being from a json response and mapping over the items with spreading over the data) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax

Object.assign({}, ...data.map(item => ({[dynamic_key]: lang})));

(when in practice it would be just n ignoring the constant)

Would I be considered correct?

0 Answers