Skip to content

Commit

Permalink
Fixed recurring decimals based on feedback. Project complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
angaaruriakhil committed Aug 30, 2021
1 parent 665a06f commit a0e931d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 9 additions & 2 deletions dist/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ function calculateAnswer() {
answer /= floatArray[i + 1];
break;
}
}
} // If the number is recurring, then round it.


return answer;
regexRecurring = /(\d)\1+/;

if (regexRecurring.test(answer)) {
return answer.toFixed(1) + " (Recurring)";
} else {
return answer;
}
}

function handleEquals(event) {
Expand Down
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ function calculateAnswer() {
break;
}
}
return answer;
// If the number is recurring, then round it.
regexRecurring = /(\d)\1+/
if (regexRecurring.test(answer)) {
return answer.toFixed(1) + " (Recurring)";
} else {
return answer;
}
}

function handleEquals(event) {
Expand Down

0 comments on commit a0e931d

Please sign in to comment.