Retrieve javascript value from js array using dynamic variable
<p>I have javascript array as follow:</p>

<pre><code>result[0] = 
Price_A:"22"
Price_B:"20"
Price_C:"19"
Price_D:"17"
Price_E:"15"
</code></pre>

<p>How can I retrieve the value using dynamic variable? Currently, I am doing like this:</p>

<pre><code>level = $('#def_level').val();
var price = 0, 
switch(level) {
    case 'A':
        price = result[0].Price_A;
        break;
    case 'B':
        price = result[0].Price_B;
        break;
    case 'C':
        price = result[0].Price_C;
        break;
    case 'D':
        price = result[0].Price_D;
        break;
    case 'E':
        price = result[0].Price_E;
        break;
    default:
        price = 'Unknown';
}
</code></pre>

<p>Is there a way to retrieve it directly using 'level' variable? What I need is something like this:</p>

<pre><code>level = $('#def_level').val();
price = result[0].Price_ + level;
</code></pre>

<p>so that it doesn't have to go through long switch process. Please help.</p>