Converting string to variable name. (JavaScript)

前端 未结 1 1268
不思量自难忘°
不思量自难忘° 2021-01-28 05:09

I did look at the previous questions, but they are for integer values and I need an answer for text values.

I asked a question relevant to this earlier in the week, but

相关标签:
1条回答
  • 2021-01-28 05:26

    You can't do what you're asking with what you have currently, but it would make more sense to create an object of the models anyway

    function Models(Make) {
        var Models = {"Acura": ['RSX','NSX','Integra'] /* snip */};
        return Models[Make][random()];
    }
    
    0 讨论(0)
提交回复
热议问题