Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ln, arcsin, arccos, and arctan #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dark-light-theme-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ let themeToggle = document.getElementById('themeToggle');

themeToggle.addEventListener('change', () => {
let lightThemeEnabled = document.body.classList.toggle('light-theme');
localStorage.setItem('light-theme-enadled', lightThemeEnabled);
localStorage.setItem('light-theme-enabled', lightThemeEnabled);
});

if (JSON.parse(localStorage.getItem('light-theme-enadled'))) {
if (JSON.parse(localStorage.getItem('light-theme-enabled'))) {
document.body.classList.add('light-theme');
themeToggle.setAttribute('checked', 'checked');
}
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ <h1>JavaScript Calculator</h1>
<div id="calculator" class="calculator">
<div id="viewer" class="viewer">You broke it!</div>


<button id="clear" class="clear">C</button>
<button data-ops="arcsin" class="ops">sin<sup>-1</sup></button>
<button data-ops="arccos" class="ops">cos<sup>-1</sup></button>
<button data-ops="arctan" class="ops">tan<sup>-1</sup></button>


<button data-ops="ln" class="ops">ln</button>
<button data-ops="sin" class="ops">sin</button>
<button data-ops="cos" class="ops">cos</button>
<button data-ops="tan" class="ops">tan</button>
Expand Down
4 changes: 2 additions & 2 deletions new_cal/dark-light-theme-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ let themeToggle = document.getElementById('themeToggle');

themeToggle.addEventListener('change', () => {
let lightThemeEnabled = document.body.classList.toggle('light-theme');
localStorage.setItem('light-theme-enadled', lightThemeEnabled);
localStorage.setItem('light-theme-enabled', lightThemeEnabled);
});

if (JSON.parse(localStorage.getItem('light-theme-enadled'))) {
if (JSON.parse(localStorage.getItem('light-theme-enabled'))) {
document.body.classList.add('light-theme');
themeToggle.setAttribute('checked', 'checked');
}
6 changes: 5 additions & 1 deletion new_cal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ <h1>JavaScript Calculator</h1>
<div id="calculator" class="calculator">
<div id="viewer" class="viewer">You broke it!</div>


<button id="clear" class="clear">C</button>
<button data-ops="arcsin" class="ops">sin<sup>-1</sup></button>
<button data-ops="arccos" class="ops">cos<sup>-1</sup></button>
<button data-ops="arctan" class="ops">tan<sup>-1</sup></button>

<button data-ops="ln" class="ops">ln</button>
<button data-ops="sin" class="ops">sin</button>
<button data-ops="cos" class="ops">cos</button>
<button data-ops="tan" class="ops">tan</button>
Expand Down
17 changes: 17 additions & 0 deletions new_cal/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ TODO:
resultNum = oldNum ** theNum;
break;

case "ln":
resultNum = Math.log(oldNum);
break;

case "sin":
resultNum = Math.sin(oldNum);
break;
Expand All @@ -126,6 +130,18 @@ TODO:
case "tan":
resultNum = Math.tan(oldNum);
break;

case "arcsin":
resultNum = Math.asin(oldNum);
break;

case "arccos":
resultNum = Math.acos(oldNum);
break;

case "arctan":
resultNum = Math.atan(oldNum);
break;

// If equal is pressed without an operator, keep number and continue
default:
Expand All @@ -134,6 +150,7 @@ TODO:

// If NaN or Infinity returned
if (!isFinite(resultNum)) {
console.log("not finite");
if (!isInt(resultNum) || !isFloat(resultNum)) { // If result is not a number; set off by, eg, double-clicking operators
resultNum = "You broke it!";
} else { // If result is infinity, set off by dividing by zero
Expand Down
6 changes: 3 additions & 3 deletions new_cal/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions new_cal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ h1 {
.calculator {
font-size: 28px;
margin: 0 auto;
width: 10em;
width: 16em;

&::before,
&::after {
Expand Down Expand Up @@ -73,7 +73,7 @@ button {
float: left;
font: inherit;
margin: 0.25em;
width: 2em;
width: 3em;
height: 2em;
transition: all 0.5s;

Expand Down
16 changes: 16 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ TODO:
resultNum = oldNum ** theNum;
break;

case "ln":
resultNum = Math.log(oldNum);
break;

case "sin":
resultNum = Math.sin(oldNum);
break;
Expand All @@ -127,6 +131,18 @@ TODO:
resultNum = Math.tan(oldNum);
break;

case "arcsin":
resultNum = Math.asin(oldNum);
break;

case "arccos":
resultNum = Math.acos(oldNum);
break;

case "arctan":
resultNum = Math.atan(oldNum);
break;

// If equal is pressed without an operator, keep number and continue
default:
resultNum = theNum;
Expand Down
6 changes: 3 additions & 3 deletions style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ h1 {
.calculator {
font-size: 28px;
margin: 0 auto;
width: 10em;
width: 16em;

&::before,
&::after {
Expand Down Expand Up @@ -73,7 +73,7 @@ button {
float: left;
font: inherit;
margin: 0.25em;
width: 2em;
width: 3em;
height: 2em;
transition: all 0.5s;

Expand Down Expand Up @@ -328,7 +328,7 @@ html.transition {

@media (min-width: 420px) {
.calculator {
width: 12em;
width: 16em;
}

.viewer {
Expand Down