JavaScript es6 use ${} for multiple state in react

For some reason I have to do this

for(let i=0;i<=6;i++){
    price.push({
        min_price: `this.state.special_${i}_min`,
        max_price: `this.state.special_${i}_max`
    });
}

But it's not what I expect, it doesn't work, it became string instead of getting the value of my states.

Answer:1

You are just assigning the string to those properties. Try using square brackets.

price.push({
    min_price: this.state[`special_${i}_min`],
    max_price: this.state[`special_${i}_max`]
});
Answer:2

I have an array that creates a conversation between two people where it 'flips' between the browser speaking and the browser listening. Short version, how do I make saySomething queue for(var i=0; ...

I have an array that creates a conversation between two people where it 'flips' between the browser speaking and the browser listening. Short version, how do I make saySomething queue for(var i=0; ...

  1. queue javascript events

I have a Node.js route that sends back some text and logs the request: app.post('/registerUser', function (req, res) { res.send('Hello World post!') console.log(req); }) Then I hit that route ...

I have a Node.js route that sends back some text and logs the request: app.post('/registerUser', function (req, res) { res.send('Hello World post!') console.log(req); }) Then I hit that route ...

  1. node inspect websockets request was expected
  2. inspect request node.js

I have this array: [{ name: "A1", arr: [1,2] }, { name: "A2", arr: [1] }] How do I can split the first one object to two objects that should contains only one array value? The result should be: [...

I have this array: [{ name: "A1", arr: [1,2] }, { name: "A2", arr: [1] }] How do I can split the first one object to two objects that should contains only one array value? The result should be: [...

  1. split array objects
  2. split array objects javascript
  3. split objects array js
  4. split array into objects
  5. split array of objects php
  6. split array of objects lodash
  7. split array of json objects
  8. split array of json objects python
  9. javascript split array of objects by property
  10. logstash split array of objects
  11. split json array into objects
  12. javascript split array into objects
  13. powershell split array of objects
  14. typescript split array of objects by property
  15. java split array of objects
  16. typescript split array of objects

I am facing issue regarding passing javascript variables to php within same function. My code looks like this else if(msg_type[i] == 'code' ){ var code_action = 'test'; <?php function ...

I am facing issue regarding passing javascript variables to php within same function. My code looks like this else if(msg_type[i] == 'code' ){ var code_action = 'test'; <?php function ...

  1. passing variable from html to javascript
  2. passing variable from javascript to php
  3. passing variable from shell script to jenkins
  4. passing variable from controller to view laravel
  5. passing variable from response to request in jmeter
  6. passing variable from parent to child angular
  7. passing variable from html to php
  8. passing variable from javascript to python
  9. passing variable from js to php
  10. passing variable from js to django view
  11. passing variable from html to node js
  12. passing variable from html to python
  13. passing variable from flask to javascript