1

I am having problems converting a string to a variable.

  • I cannot use an eval() because the code is ran through another eval
  • I have no access to window.

I have tried running an IIFE function no success

I have tried these stackoverflow answers

How do i convert a string to a variable?

For clarity why

myObject = {
  name: 'alexander',
  color: 'grey'
}

for (const key of Object.keys(myObject)) {
        db.friends.update(2, {
          key: "Test data"})

      }

A workaround to this could also be helpful.

Could I trim?

xaander1
  • 1,064
  • 2
  • 12
  • 40
  • i could use if statements on `key` but that would mean i would have to repeat the same `query` several times which is what amt trying to avoid – xaander1 Sep 25 '19 at 10:38
  • 2
    Not sure what the example should demonstrate. Do you want to have a dynamic property name? `{[column]: "Test data"}` or maybe `{[key]: "Test data"}`. A property is not a variable though, which is why it's unclear how the code relates to the description of your problem. You are not doing anything with `key`, so it's unclear to me how you intend to use it. – Felix Kling Sep 25 '19 at 10:39
  • 1
    What is the input string, and what is the desired output? – mbojko Sep 25 '19 at 10:41

0 Answers0