How to write values ​​from JS to separate variables?

  • 0
    Let's say there is a code like this:
    <script>
    var ro_zero = false;ro_prices = {};
    ro_prices[2231] = {};
    ro_prices[2231]['price'] = 18910.0000;
    ro_prices[2231]['discounts'] = [];
    ro_prices[2231]['specials'] = [];
    ro_prices[2232] = {};
    ro_prices[2232]['price'] = 21000.0000;
    ro_prices[2232]['discounts'] = [];
    ro_prices[2232]['specials'] = [];
    ro_prices[2233] = {};
    ro_prices[2233]['price'] = 35880.0000;
    ro_prices[2233]['discounts'] = [];
    ro_prices[2233]['specials'] = [];
    ro_prices[2234] = {};
    ro_prices[2234]['price'] = 38360.0000;
    ro_prices[2234]['discounts'] = [];
    ro_prices[2234]['specials'] = [];
    ro_prices[2235] = {};
    ro_prices[2235]['price'] = 22560.0000;
    ro_prices[2235]['discounts'] = [];
    ro_prices[2235]['specials'] = [];
    ro_prices[2236] = {};
    </script>

    The IDs in square brackets and the equalities (21000.0000, 35880.0000, 38360.0000, 22560.0000) are always different and I cannot know them in advance.
    How can I write 21000.0000, 35880.0000, 38360.0000, 22560.0000 into separate variables so that I can then substitute them into the markup?
    Let's say I know in advance that there is a number 18910.0000
    The idea is something like this: get an ID 18910.0000 [2231] and dance from him according to the following values.
    JavaScript Eden Melendez, Feb 23, 2020

  • 1 Answers
  • 0

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!