Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

splitting a dynamic string to store in separate variable

I have a dynamic string like below one getting from server.it may be more than 2.

[{text :'AC Maintenance today ', value:16.00, color: '#DEE3E8'},{text :'test3', value:150.00, color: '#5A0C55'}]

How to get each values in a separate js variable.
for eg

var text = ["AC Maintenance today","test3"];
var value = [16.00,150.00];
var color = ["#DEE3E8","#5A0C55"]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

var values = [{text :'AC Maintenance today ', value:16.00, color: '#DEE3E8'},{text :'test3', value:150.00, color: '#5A0C55'}]

const text = values.map((v) => v.text)
const value= values.map((v) => v.value)
const color= values.map((v) => v.color)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading