JSFiddle - React, Tailwind, and code Playground
by jhu26
HTML
<html>
<head> This is a practice set for simple math operations
<script>
</script>
<body>
The practice sets will provide examples of basic math operations such as: Addition, Subtraction, Multiplication, Division, Remainder, and Operator Precedence
</body>
</head>
</html>
JavaScript
"use strict";
//Addition (Adds two numbers together)
var x = 10; // x contains the value 10
var y = 50; // y contains the value 50
var result = x + y
console.log(result);
//Subtraction (Subtracts the right number from the left)
var x = 10; // x contains the value 10
var y = 50; // y contains the value 50
var result = x - y
console.log(result);
//Multiplication (Multiplies two numbers together)
var x = 10; // x contains the value 10
var y = 50; // y contains the value 50
var result = x * y
console.log(result);
//Division (Divides the left number by the right)
var x = 10; // x contains the value 10
var y = 50; // y contains the value 50
var result = x / y
console.log(result);
//Remainder (Returns the remainder left over after you've divided the left number into a number of integer portions equal to the right number)
var x = 10; // x contains the value 10
var y = 50; // y contains the value 50
var result = x % y
console.log(result);
//Showing Operator Precedence
var w = 10; // w contains the value 10
var x = 50; // x contains the value 50
var y = -6; // y contains the value -6
var z = 100; //z contains the value 100
// var result = w + x / y + z (In JavaScript, the operations for multiply and divide are always completed before add and subtract. Thus, if you want to override Operator Precedence, then you'll need to add in parentheses around the parts that you want to explicitly done first.)
var result = (w + x) / (y + z)
console.log(result);