Basic Algebraic Math hacks

Q1 (Exponents):

A cube has a side length of 6 units. What is its volume?

%%javascript
// Q1: Exponents — volume of a cube with side length 6
const side = 6;
const volume = side ** 3; // same as Math.pow(side, 3)
console.log('Q1 - Volume of cube (side 6):', volume);
<IPython.core.display.Javascript object>

Q2 (PEMDAS):

Evaluate the expression:

(7+14)*5/12 + 2

%%javascript
// Q2: PEMDAS — evaluate (7+14)*5/12 + 2
const resultQ2 = (7 + 14) * 5 / 12 + 2;
console.log('Q2 - Result of (7+14)*5/12 + 2:', resultQ2);
<IPython.core.display.Javascript object>

Q3 (Algorithm):

Write JavaScript code where you define variables and run commands that find the values of operations you apply onto them

%%javascript
// Q3: Algorithm — define variables and apply operations
let a = 8;
let b = 3;
// perform some operations
let sum = a + b;
let product = a * b;
let average = (a + b) / 2;
console.log('Q3 - a:', a, 'b:', b);
console.log('sum:', sum, 'product:', product, 'average:', average);
console.log({ a, b, sum, product, average });
<IPython.core.display.Javascript object>

Diagram showing mathematical operations