<!DOCTYPE html>
<html>
	<input id="exercise" placeholder="種目">
<input id="count" type="number" placeholder="回数">
<button onclick="save()">記録</button>

<ul id="list"></ul>

<script>
function save() {
  const ex = document.getElementById("exercise").value;
  const count = document.getElementById("count").value;

  const data = JSON.parse(localStorage.getItem("train")) || [];
  data.push({ ex, count });

  localStorage.setItem("train", JSON.stringify(data));
  render();
}

function render() {
  const list = document.getElementById("list");
  const data = JSON.parse(localStorage.getItem("train")) || [];
  list.innerHTML = "";

  data.forEach(d => {
    list.innerHTML += `<li>${d.ex}：${d.count}</li>`;
  });
}

render();
</script>

/ 先頭へ
</html>
