Question: So In my node I do an API and send it to my `index.ejs` page like

```
app.get("/", function (req, res) {
  request("http://something/API", function (error, response, body){
    if(!error && response.statusCode == 200) {
      var result = JSON.parse(body) //Converts it into object
      console.log(result)
      res.render("home.ejs", {result:result});
    }
  })
})

```

Now In my Index Page, I do something like this 

```
 <% for ( var i= 0; i<result.length; i++ ) { %>
<table text-aling="left">
  <tr>
  <td> <%= i+1 %>  </td>
  <td> <p class="c"><%=result[i]["long"]%></p>  (<%= result[i]["short"] %>) </td>
  <td> <%= result[i]["price"] %> </td>

```

followed by a script just below `body` and `head tag` to do DOM manipulation.

```
<script type="text/javascript">
  var x =  document.getElementsByClassName("c")[1].value
  console.log(x);
</script>

```

Now, `Console.log(x)` says undefined (while it does display result from API call on my frontend. Is it because it is an object? or what am I missing here? How can I get the value displayed on my frontend at my `console.log`

Answer: 
Your `<p>` does not have a `value` attribute. Use `innerHTML`:

```
x =  document.getElementsByClassName("c")[1].innerHTML

```
I think the issue you are experiencing could be due to one of a few problems:

1. The placement of the tag

Make sure you place the script tag at the bottom of your html to ensure the above elements have fully rendered before the script is called. If the script runs before the elements with class "crypto" have loaded, the variable 'x' will be empty.

2. The number of elements with the class "crypto"

While I don't see any elements with class "crypto" in your example, you are trying to set variable 'x' to the element in the array at index 1 (the second position). If you have fewer than two elements with the class "crypto", trying to select index 1 will be undefined. If you're trying to select the first element with the class "crypto", use "var x = document.getElementsByClassName("crypto")[0].value" instead.

3. The presence of the class "crypto"
I see you list an element with the class "c", though none with the class "crypto". If you are trying to select the element with class "c", , use "var x = document.getElementsByClassName("c")[0].value" instead.