Of course, you can. Here is an example of the code I used in a To-do app just like you:
try {
localStorage.setItem("memo_list", JSON.stringify(list));
alert('The memo is successfully saved.');
} catch (e) {
alert('Error saving to storage.');
throw e;
}