quick question:
I want to use spread operator to push elements in my to-dos array. It works, when i declare an array and use it in creator function with spread syntax in same js file.
However, i want to use a dedicated main.js or helper.js file to store my to-dos array.
in my helpers.js i have
let toDoArray = []
...
export { inputItems, toDoArray, toDosWrapper };
in my newToDo.js i have
import { inputItems, toDoArray } from './helpers.js';
...
function addToDoArray(toDo) {
toDoArray = [...toDoArray, toDo()];
console.log(toDoArray);
printToDos(toDoArray);
}
...
So it throws this error:
Uncaught TypeError: "toDoArray" is read-only