У меня выходит так
А должно вот так
КОД:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" class="input"><br>
<br>
<textarea class="text"></textarea>
<button class="read">Вывести</button>
<h3 class="out"></h3>
<script type="module" src="script.js"></script>
<script type="module" src="listScript.js"></script>
</body>
</html>
let button = document.querySelector('.read');
button.onclick = () =>{
fan1();
};
let todoList = [];
let heaList = [];
function fan1 () {
let text = document.querySelector('.text');
let temp = {};
temp.todo = text.value;
temp.check = false;
let i = todoList.length;
todoList[i] = temp;
//result.innerHTML = temp.todo;
out();
}
function out() {
let input = document.querySelector('.input').value;
let result = document.querySelector('.out');
let name = {};
name.todo = input;
name.check = false;
let j = heaList.length;
heaList[j] = name;
let out = '',
res = '', res2 = '';
for (let key in todoList) {
res2+=todoList[key].todo + '<br>';
}
for (let key1 in heaList) {
res+=heaList[key1].todo + '<br>';
}
out += '<span>'+ res + res2 + '</span><br>'
result.innerHTML = out; // heaList[j].todo + '<br>' + todoList[i].todo + '<br>'
}