JS Even & Odd with Loops

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    for(var a = 1; a <= 10; a++){
      if(a % 2 == 0){
        document.write(a + "<br>");
      }
    }
  </script>
</head>
<body>
</body>
</html>