Trying to create a JavaScript object/array...?

You are a master :grinning:

It’s a concise approach, the only thing I noticed is that it’s adding the words “text” and “value” in quotation marks which throws an error in the JavaScript side. What would you suggest for that?

It probably means that the quotes are not actually quotes, if you copied them over.

What I meant is
text:
and
value:
cannot be surrounded in quotation marks. This will throw an error in JavaScript
"text":
"value":
because it takes these as strings, not object parameters

{
	"choices[]": {
		"Abarth": {
			"text": [
				"500"
			],
			"value": [
				1
			]
		},
		"AC": {
			"text": [
				"Cobra"
			],
			"value": [
				2
			]
		},
		"Alfa Romeo": {
			"text": [
				"4C",
				"156",
				"Brera",
				"159"
			],
			"value": [
				5,
				3,
				6,
				4
			]
		}
	}
}

Is valid JSON, but JavaScript still needs to parse the data to make it usable.

https://www.w3schools.com/js/js_json_parse.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service