I am trying to call a set of elements from an HTML doc by class name, which I understand returns them as an array-like object. I would like to cycle through the values of this array in a for loop, but the loop is returning 'undefined' for every value in the array, even though there is definitely a value in the elements that I am calling.

I basically want to output the following onto the web page, into some simple div elements:

Age prediction line 1: Hello George, you are 28 in 2019

Age prediction line 2: Hello Andy, you are 29 in 2020

Age prediction line 3: Hello Kyle, you are 30 in 2021

Age prediction line 4: Hello Jenny, you are 31 in 2022

The names are the values of the elements in the "myinput" class. I am using a pretty standard for loop as below:

```
const years = [2019, 2020, 2021, 2022];

var name = document.getElementsByClassName("myinput");
var age = document.getElementById("agefield").value;

var intage = parseInt(age, 10);

for (i = 0; i < 4; i++) {
  document.getElementsByClassName("ageprediction")[i].innerHTML = "Age 
  prediction line " + (i+1) + ": ";
  document.getElementsByClassName("testdiv")[i].innerHTML = " Hello " + 
  name[i].value + " you are " + [intage+i] + " in " + years[i];
}

```

There is just one agefield element, and calling that by Id, adding.value and converting to an integer works fine. But after understanding and reading everywhere that you could use code like this to cycle through the elements of a getElementbyClass array in a for loop using the current index value, I am still getting 'undefined' as the result. Is this because name[i].value is not the correct code?

UPDATE: A couple of people asked to see the relevant HTML as well, here it is:

```
<section id="form">

  <input class="myinput" value="George"/><br/><br/>
  <input class="myinput" value="Andy"/><br/><br/>
  <input class="myinput" value="Kyle"/><br/><br/>
  <input class="myinput" value="Jenny"/><br/><br/>

  <input id="agefield" placeholder="Your age" value="28"/><br/><br/>

  <div class ="ageprediction"></div><div class = "testdiv">Testing</div><br/><br/>
  <div class ="ageprediction"></div><div class = "testdiv">Testing</div><br/><br/>
  <div class ="ageprediction"></div><div class = "testdiv">Testing</div><br/><br/>
  <div class ="ageprediction"></div><div class = "testdiv">Testing</div><br/><br/>

</section>

```

As you can see, I'm just using predefined values in the inputs for now for testing purposes.