TheSanches,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script>
window.addEventListener("DOMContentLoaded", function() {
var comNum = localStorage.getItem("coment"),
but = document.querySelector("#com-check"),
out = document.querySelector("#com-out");
if (!comNum) {
comNum = 0;
but.addEventListener("click", function rating() {
comNum++;
localStorage.setItem("coment", comNum);
out.innerHTML = comNum;
but.removeEventListener("click", rating);
});
}
out.innerHTML = comNum;
});
</script>
</head>
<body>
<div id="com">
<button id="com-check">Нравиться</button>
<div id="com-out"></div>
</div>
</body>
</html>