Skip to content

Commit

Permalink
log(), ln(), and fact() improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rizalfahlevi8 committed Jun 10, 2024
1 parent b008120 commit f6ae914
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function logaritma() {
i = data.result;
log = Math.log10(data.result);
data.result = log;
if (data.formats.length > 0 && data.formats[data.formats.length - 1].includes("log")) {
if (data.formats.length > 0 && /(ln|log|fact)/.test(data.formats[data.formats.length - 1])) {
j = data.formats[data.formats.length - 1];
data.formats.pop();
data.formats.push(`log(${j})`);
Expand All @@ -125,12 +125,11 @@ function logNatural() {
result.value = data.result;
operation.value = data.formats.join('');
data.staging = [];
console.log(data);
} else if (data.result !== 0 || data.result === 0) {
i = data.result;
ln = Math.log(data.result);
data.result = ln;
if (data.formats.length > 0 && data.formats[data.formats.length - 1].includes("ln")) {
if (data.formats.length > 0 && /(ln|log|fact)/.test(data.formats[data.formats.length - 1])) {
j = data.formats[data.formats.length - 1];
data.formats.pop();
data.formats.push(`ln(${j})`);
Expand All @@ -142,6 +141,7 @@ function logNatural() {
result.value = data.result;
operation.value = data.formats.join('');
}
console.log(data);
}

//------------------ SQUAREROOT ------------------------
Expand Down Expand Up @@ -190,7 +190,7 @@ function factorial() {
i = data.result;
fact = factorialCalculation(data.result);
data.result = fact;
if (data.formats.length > 0 && data.formats[data.formats.length - 1].includes("fact")) {
if (data.formats.length > 0 && /(ln|log|fact)/.test(data.formats[data.formats.length - 1])) {
j = data.formats[data.formats.length - 1];
data.formats.pop();
data.formats.push(`fact(${j})`);
Expand Down

0 comments on commit f6ae914

Please sign in to comment.