Why I can’t exit the Fullscreen using esitFullscreen method?

Whenever I try to exit the Fullscreen in the console it shows that exitFullscreen is not a function

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>

<body>
  <button onclick="o()">O</button>
  <button onclick="x()">X</button>
  
<script type="text/javascript" charset="utf-8">
  function o(){
   document.documentElement.requestFullscreen();
  }
   function x(){
   document.documentElement.exitFullscreen();
   }
  
</script>
</body>

</html>

From the code above by clicking on button x I should exit Fullscreen but it is not happening

Answer

Look at the documentation.

requestFullscreen is a method on elements

exitFullscreen is a method on the document