I tried to access the width of a div using javascript, but every time it is printing NaN no matter what i set it. I am new to javascript, what is wrong with my code ?
    <html>
    <head>
        <title>hello</title>
        <style type="text/css">
      #base
      {
        width:300px;
        height:30px;
        background-color: black;
      }
      #scr
      {
        height:30px;
        width:10px;
        background-color: red;
      }
    </style>
    <script type="text/javascript">
    var magic = function()
    {
    console.log("inside magic")
    var d = document.getElementById("scr");
    var b =  d.style.width;
    console.log(b);
    b = parseInt(b);
    console.log(b);
    }
    </script>
    </head>
    <body>
    <div id="base">
    <div id = "scr" >
    </div>
    </div>
    <br>
    <button onclick="magic()">Magic</button>
    </body>
</html>
 
     
     
    