<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p></p>
<button>+</button>
</body>
<script>
let p = document.querySelector('p');
let btn = document.querySelector('button');
let k = 0;
if (localStorage.getItem('arr') === null ) {
localStorage.setItem('arr', '[]');
}
let arr = JSON.parse(localStorage.getItem('arr'));
btn.addEventListener('click', function () {
k++;
arr.push(k);
localStorage.setItem('arr', JSON.stringify(arr));
});
</script>
</html>