Replace the surrounding three lines with

    serverEnabled.checked = localStorage.getItem("serverEnabled") == "true";

(the `.checked` property is a boolean, not a string..)