JS Dasar: 10. operator aritmatika

by istiq20

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Operator aritmatika</title>
  </head>
  <body>
    <script>
      //operator + (pertambahan)
      let result = 1 + 2; // 3
      document.writeln("<p>1 + 2 = " + result + "</p>");
      let originalResult = result; // 3

      //operator - (pengurangan)
      result = result - 1; // 2
      document.writeln("<p>" + originalResult + " - 1 = " + result + "</p>");
      originalResult = result; // 2

      //operator * (perkalian)
      result = result * 2; // 4
      document.writeln("<p>" + originalResult + " * 2 = " + result + "</p>");
    </script>
  </body>
</html>