-1

How do I get to, Value, Editions, Price, Average?

My non working code:

.append(th.clone().text(value.editions[0].price[1].average))

The JSON layout:

{
  "name": "About Face",
  "id": "about-face",
  "url": "https://api.deckbrew.com/mtg/cards/about-face",
  "store_url": "http://store.tcgplayer.com/magic/urzas-legacy/about-face",
  "types": [
    "instant"
  ],
  "colors": [
    "red"
  ],
  "cmc": 1,
  "cost": "{R}",
  "text": "Switch target creature's power and toughness until end of turn.",
  "formats": {
    "commander": "legal",
    "legacy": "legal",
    "vintage": "legal"
  },
  "editions": [
    {
      "set": "Urza's Legacy",

      "price": {
        "low": 89,
        "average": 154,
        "high": 198
      },
      "url": "https://api.deckbrew.com/mtg/cards?multiverseid=12414",

    }
  ]
}

My Fiddle can be found here:

http://jsfiddle.net/w2QHz/13/

3
  • 2
    value.editions[0].price.average - price is an object not an array so there is no need to use an index based access Commented Jun 18, 2014 at 2:35
  • You should add the line in question into the JSFiddle. Commented Jun 18, 2014 at 2:38
  • it was suppose to be there.... anyway, I just updated, but not working. Commented Jun 18, 2014 at 3:09

1 Answer 1

1

You should use

.append(th.clone().text(value.editions[0].price.average))

Remove [0] from price, since price is an object not an array.

Sign up to request clarification or add additional context in comments.

3 Comments

update, it worked with high and low, just not average... not sure if it has anything to do with those being the first and last within 'price'.
@user3730047 If it worked with high and low then the property access worked correctly so please upvote the answer. As for 'average' I suspect there is a typo on either end which is why you can't get the value. Alternatively the function calculating the average is not functioning correctly and you aren't getting an average value correctly. Please post another question on that with details on the average calculation. Thanks.
Looks like average is actually median, so you are correct.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.