Skip to content

Commit 90f78ee

Browse files
authored
Update index.html
1 parent 249ea38 commit 90f78ee

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

index.html

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -884,30 +884,25 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
884884

885885
// Helper: Finds closest rad(x) match for given function (sin or cos)
886886

887-
function findClosestRad(value, funcType) {
887+
function findClosestRad(value) {
888888
let closestKey = null;
889889
let minDiff = Infinity;
890890

891891
for (const key in trig) {
892-
if (!trig[key][funcType]) continue;
893-
const keyMatch = key.match(/rad\(([\d.]+)\)/);
894-
if (!keyMatch) continue;
892+
const match = key.match(/rad\(([\d.]+)\)/);
893+
if (!match) continue;
895894

896-
const radVal = parseFloat(keyMatch[1]);
897-
const diff = Math.abs(radVal - value);
895+
const rad = parseFloat(match[1]);
896+
const delta = Math.abs(rad - value);
898897

899-
if (diff < minDiff) {
900-
minDiff = diff;
898+
if (delta < minDiff) {
899+
minDiff = delta;
901900
closestKey = key;
902901
}
903-
904-
905-
if (closestKey) {
906-
const approxVal = trig[closestKey][funcType].value;
907-
return `${funcType}(${closestKey}) ≈ ${approxVal}`;
908902
}
909-
}
910-
}
903+
904+
return closestKey ?? null;
905+
}
911906

912907
function sin(input) {
913908
// Normalize input: remove spaces, handle cases like "sin 0533" or "sin(0.533)"

0 commit comments

Comments
 (0)