bless
bless

Reputation: 12

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"]

Upvotes: 0

Views: 108

Answers (1)

Sooraj Jose
Sooraj Jose

Reputation: 544

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)

Upvotes: 2

Related Questions