Because you are calling the setCookie(...) method. Try the following:
en.onclick = setCookie;
Using parentheses, you call the method; without you passing it as an object.
Or try the following:
en.onclick = function() { setCookie('english') };
Here we create a new function that calls setCookie with the appropriate argument.
source share