css: property can not be set & # 39; className & # 39; by null on setThemeFromCookie

I am coding in wordpress to make a button to toggle the body type from light mode to dark mode. I was experimenting with trying to add a cookie to remember browser preference. But I receive an error. Unable to set the property & # 39; className & # 39; of null in setThemeFromCookie.

In addition, when you click on the button another error appears (index): 486 Uncught TypeError: property can not be read & # 39; className & # 39; from null on togglePageContentLightDark

My url is https://milyin.com
You can see the button in blue color located at the bottom of the page.

JS follows
function togglePageContentLightDark () {
var body = document.getElementById (& # 39; body & # 39;)
var currentClass = body.className
var newClass = body.className == & # 39; dark-mode & # 39 ;? & # 39; mode of light & # 39 ;: & # 39; mode of darkness & # 39;
body.className = newClass

        document.cookie = & # 39; theme = & # 39; + (newClass == & # 39; light-mode & # 39 ;? & # 39; light & # 39 ;: & # 39; dark & ​​# 39;)
console.log (& # 39; Cookies are now: & # 39; + document.cookie)
}

function isDarkThemeSelected () {
returns document.cookie.match (/ theme = dark / i)! = null
}

function setThemeFromCookie () {
var body = document.getElementById (& # 39; body & # 39;)
body.className = isDarkThemeSelected ()? & # 39; dark mode & # 39 ;: & light mode & # 39;
}

(function () {
setThemeFromCookie ()
}) ();

HTML for the button


I'm quite new to the Java script and this code was taken only from the Internet. Please, help me debug this code.