JSFiddle - React, Tailwind, and code Playground

HTML

<p>The following function works of course:</p>

<button onclick="One()">Function One</button>

<p>I need to get this function to work now, so I can have a variable select from myarray:</p>

<button onclick="Two()">Function Two</button>

JavaScript

var myarray = {bricks:3000, studs:500, shingles:400, tiles:700};

function One() {
       alert(myarray.bricks);
}


var myvalue = "bricks"  //supplied here to make example work

function Two() {
       alert(myarray[myvalue]);
}