Question: I know there's definitely a better way to do this but I can't seem to figure it out. I know that I need to create a loop but that's about it:

```
function loadData() {
  var getInput1 = localStorage.getItem("input1")
  var parsedInput1 = JSON.parse(getInput1)
  $("#planner-input-1").val(parsedInput1)
  //--------------------------------------

  var getInput2 = localStorage.getItem("input2")
  var parsedInput2 = JSON.parse(getInput2)
  $("#planner-input-2").val(parsedInput2)
  //--------------------------------------

  var getInput3 = localStorage.getItem("input3")
  var parsedInput3 = JSON.parse(getInput3)
  $("#planner-input-3").val(parsedInput3)
  //--------------------------------------

// etc etc etc...

```

Answer: 
You can iterate over the indices, from 1 to however many you have, and concatenate it with `input` to look up the appropriate property on `localStorage`:

```
function loadData(){
  for (let i = 1; i < 10; i++) {
    const parsed = JSON.parse(localStorage.getItem("input" + i));
    $("#planner-input-" + i).val(parsed);
  }
}

```

But it would be better to re-structure your data and HTML - use an array in local storage instead, and use classes instead of IDs, so you can do something like this instead:

```
function loadData(){
  const inputs = document.querySelectorAll('.planner-input');
  const parsedArr = JSON.parse(localStorage.getItem("inputs"));
  inputs.forEach((input, i) => {
    input.value = parsedArr[i];
  });
}

```

Using this method, the first item in the local storage array will correspond to the value to be put into the first `.planner-input`, and so on.
Use an array of objects to do the work.
---------------------------------------

Here is another method of processing the data where the ids are predefined. Your example worries me that your data is out of shape and will end up biting you, but without more details I have no recommendations. Hope this helps!

```js
function loadItem(dataId, selector) {
  var parsedInput = JSON.parse(dataId)
  $("selector").val(parsedInput)
}

function loadData() {
  var itemsToProcess = [{
      dataId: input1,
      selector: '#planner-input-1'
    },
    {
      dataId: input2,
      selector: '#planner-input-2'
    },
    {
      dataId: input3,
      selector: '#planner-input-3'
    }
  ]

  itemsToProcess.forEach(function(item) {
    loadItem(item.dataId, item.selector);
  })
  // OR
  for (let item of items) {
    loadItem(item.dataId, item.selector);
  }
}
```