website

source code for the ttmaths.uk website
Log | Files | Refs | README

commit 86f0a5c2f5bf48ee979421e8a065afe969144cfa
parent 36c7430ca5bf7cbe258333b852af89cf334ffb61
Author: hrryt <harry@mayesfield.uk>
Date:   Mon, 17 Aug 2026 13:08:11 +0100

Format return if statements without braces

Diffstat:
Msrc/components/Question.jsx | 2+-
Msrc/components/plotting/Cubic.jsx | 2+-
Msrc/components/plotting/Plot.jsx | 4++--
Msrc/components/questions/AddingFractionsQuestion.jsx | 2+-
Msrc/components/questions/QuadraticEquationQuestion.jsx | 10+++++-----
Msrc/scripts/formatUtils.js | 8++++----
Msrc/scripts/graphUtils.js | 2+-
Msrc/scripts/mathsUtils.js | 2+-
8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/components/Question.jsx b/src/components/Question.jsx @@ -1,7 +1,7 @@ import Equation from './Equation.jsx'; function maybeEquation(expression) { - if (typeof expression == 'string') { return <Equation equation={expression} />; } + if (typeof expression == 'string') return <Equation equation={expression} />; return expression; } diff --git a/src/components/plotting/Cubic.jsx b/src/components/plotting/Cubic.jsx @@ -17,7 +17,7 @@ function getDepressedCubicRoots(a, b, c, d) { if (discriminantish === 0) { // https://en.wikipedia.org/wiki/Cubic_equation#Multiple_root - if (p === 0) { return [0,0,0]; } + if (p === 0) return [0,0,0]; const doubleRoot = -3*q/(2*p); return [3*q/p, doubleRoot, doubleRoot]; } diff --git a/src/components/plotting/Plot.jsx b/src/components/plotting/Plot.jsx @@ -28,14 +28,14 @@ function AxisTicks() { <g> {Array.from({ length: p.width - 1 }).map((_, i) => { const x = i + p.minX + 1; - if (x % every || x === 0) { return; } + if (x % every || x === 0) return; return <Label point={[x, 0]} position="bottom">{x}</Label>; })} </g> <g> {Array.from({ length: p.height - 1 }).map((_, i) => { const y = i + p.minY + 1; - if (y % every || y === 0) { return; } + if (y % every || y === 0) return; return <Label point={[0, y]} position="left">{y}</Label>; })} </g> diff --git a/src/components/questions/AddingFractionsQuestion.jsx b/src/components/questions/AddingFractionsQuestion.jsx @@ -7,7 +7,7 @@ function getRandomFraction(seed) { const num0 = getRandomInt(1, 5, seed++); const denom0 = getRandomInt(2, 10, seed++); const [num, denom] = simplifyFraction(num0, denom0); - if (denom == 1) { return getRandomFraction(seed++); } + if (denom == 1) return getRandomFraction(seed++); return [num, denom]; } diff --git a/src/components/questions/QuadraticEquationQuestion.jsx b/src/components/questions/QuadraticEquationQuestion.jsx @@ -11,15 +11,15 @@ function formatQuadraticExpression(a, b, c) { } function formatRoots(l, m, n, o) { - if (m / l == o / n) { return `x = ${formatFraction(-m, l)}`; } - if (-m / l == o / n) { return `x = \\pm ${formatFraction(Math.abs(-m), l)}`; } + if (m / l == o / n) return `x = ${formatFraction(-m, l)}`; + if (-m / l == o / n) return `x = \\pm ${formatFraction(Math.abs(-m), l)}`; return `x = ${formatFraction(-m, l)} \\text{ or } x = ${formatFraction(-o, n)}`; } function formatFactor(x_coeff, const_coeff) { - if (const_coeff == 0) { return "x"; } - const fx_coeff = formatCoefficient(x_coeff, { showPlus: false, showOne: false, showZero: false, suffix: 'x'}) + if (const_coeff == 0) return "x"; + const fx_coeff = formatCoefficient(x_coeff, { showPlus: false, showOne: false, showZero: false, suffix: 'x' }) const fconst_coeff = formatCoefficient(const_coeff, { showPlus: true, showOne: true, showZero: false }) return `(${fx_coeff}${fconst_coeff})`; } @@ -34,7 +34,7 @@ function formatFactors(l, m, n, o) { o = o / hcf2 const fFrontCoefficient = formatCoefficient(frontCoefficient, {showPlus: false, showOne: false, showZero: true}) - if (l == n && m == o) { return `${fFrontCoefficient}${formatFactor(l, m)}^2`} + if (l == n && m == o) return `${fFrontCoefficient}${formatFactor(l, m)}^2` return `${fFrontCoefficient}${formatFactor(l, m)}${formatFactor(n, o)}` } diff --git a/src/scripts/formatUtils.js b/src/scripts/formatUtils.js @@ -5,7 +5,7 @@ export function formatVec(arr) { } export function formatCoefficient(x, parameters = { showPlus: false, showOne: true, showZero: true, suffix: '' }) { - if (!parameters.showZero && x == 0) { return ''; } + if (!parameters.showZero && x == 0) return ''; const plus = parameters.showPlus ? '+' : ''; const sign = x < 0 ? '-' : plus; x = Math.abs(x); @@ -15,8 +15,8 @@ export function formatCoefficient(x, parameters = { showPlus: false, showOne: tr // this thing is probably begging for bugs from simplification and zeroes. export function formatFraction(num, denom, parameters = { showPlus: false, showOne: true, showZero: true, simplify: false, suffix: '' }) { - if (!parameters.showZero && num == 0) { return ''; } - if (getHCF(num, denom) == denom && parameters.simplify) { return formatCoefficient(simplifyFraction(num, denom)[0], parameters)} + if (!parameters.showZero && num == 0) return ''; + if (getHCF(num, denom) == denom && parameters.simplify) return formatCoefficient(simplifyFraction(num, denom)[0], parameters) const plus = parameters.showPlus ? '+' : '' const sign = num / denom < 0 ? '-' : plus @@ -31,7 +31,7 @@ export function formatFraction(num, denom, parameters = { showPlus: false, showO } export function formatLine(line) { - if (line.b == 0) { return `x = ${formatFraction(-line.c, line.a, { showPlus: false, showOne: true, showZero: true, simplify: true })}`; } + if (line.b == 0) return `x = ${formatFraction(-line.c, line.a, { showPlus: false, showOne: true, showZero: true, simplify: true })}`; let mxTerm = formatFraction(-line.a, line.b, { showPlus: false, showOne: false, showZero: false, simplify: true, suffix: 'x' }) const cTerm = formatFraction(-line.c, line.b, { showPlus: false, showOne: true, showZero: false, simplify: true }) if (!mxTerm && !cTerm) { diff --git a/src/scripts/graphUtils.js b/src/scripts/graphUtils.js @@ -38,6 +38,6 @@ export function getSymmetricBounds(midX, dx, p) { } export function getColourClass(colour) { - if (colour == 'auto') { return ''; } + if (colour == 'auto') return ''; return `color-${colour}`; } diff --git a/src/scripts/mathsUtils.js b/src/scripts/mathsUtils.js @@ -1,5 +1,5 @@ export function getHCF(a, b) { - if (a == 1 && b == 1) { return 1 } + if (a == 1 && b == 1) return 1; return b == 0 ? a : getHCF(b, a % b); }