I'm making a simple note app. Each note has a title, a body and a complete status. I want to create it so that if a note is not completed, it creates a button under the note. Upon clicking the button it should change the boolean value of complete to true and repopulate the list.
The problem I'm experiencing is that if the title has a space in it, I get an error:

This only happens when there is a space in the title(clicked on Family time). Does anyone know what the issue is? I've tried to create note.title as a variable then add it in. I've also tried to note.title.toString() with no luck. Here is the function:
function populateList(theList)
{
let divList = document.querySelector('#ListDiv');
divList.innerHTML = "";
theList.forEach(function(note)
{
let element = document.createElement('p');
let titleName = note.title.toLowerCase();
element.innerHTML = `Title: ${note.title}<br>Body: ${note.body}<br>Completed:${note.completed}`;
if(note.completed == false)
{
element.innerHTML += `<br><button onclick=completeNote("${note.title}")>Complete</button>`;
}
divList.appendChild(element);
});
}
element.innerHTML += `<br><button onclick='completeNote("${note.title}")'>Complete</button>`;