Saving user choice on local storage - need a help

I need a help here, I am trying to save user choice in localstorage and reuse it when user visit again, not working as expected, what I am doing wrong here

All values saved to localstorage are strings. You will need to convert your “true” and “false” values back to Boolean values to use your existing if statements or you change your if statement comparisons.

FYI - You can simplify your code to:

const body = document.getElementById('app');
function setBackgroundColor(){ = localStorage.darkTheme == "true" ? '#ff0088' : '#eeeeee';

body.addEventListener('click', function(e){
  localStorage.darkTheme = === 'dark';

1 Like

hey thank you very much