Skip to content

Commit

Permalink
dwdw
Browse files Browse the repository at this point in the history
  • Loading branch information
alvitodev authored Dec 25, 2023
1 parent b2f747b commit aa18317
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ <h1 id="toast">Calculator</h1>
</div>
<div class="first-row">
<input type="text" name="result" id="result" placeholder="Result" readonly />
<input type="button" value="C" onclick="result.value=''" id="clear-button" />
<input type="button" value="AC" onclick="result.value=''" id="clear-button" />
<input type="button" value="C" onclick="deleteOneChar()" id="clear-button" />
</div>
<div class="second-row">
<input type="button" value="1" onclick="liveScreen(1)" />
Expand Down
10 changes: 10 additions & 0 deletions app/calculator/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,22 @@ function calculate(value) {
result = "Invalid operator";
}



// Menampilkan hasil di layar
res.value = result;

console.log(value)
}

// Menghapus 1 karakter di text
function deleteOneChar() {
const resultInput = document.getElementById("result");
if (resultInput.value.length > 0) {
resultInput.value = resultInput.value.substring(0, resultInput.value.length - 1);
}
}

// Swaps the stylesheet to achieve dark mode.
function changeTheme() {
const theme = document.getElementById("theme");
Expand Down

0 comments on commit aa18317

Please sign in to comment.