Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c15c48

Browse files
fix: check number
1 parent 32d4b1d commit 9c15c48

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎067-expense tracker/script.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,19 @@ function generateID() {
3939

4040
function addTransaction(e) {
4141
e.preventDefault();
42-
if (text.value.trim() === "" || amount.value.trim() === "") {
42+
const amountValue = Number(amount.value);
43+
if (
44+
text.value.trim() === "" ||
45+
isNaN(amountValue) ||
46+
amount.value.trim() === ""
47+
) {
4348
showNotification();
49+
return;
4450
} else {
4551
const transaction = {
4652
id: generateID(),
4753
text: text.value,
48-
amount: +amount.value,
54+
amount: amountValue,
4955
};
5056
transactions.push(transaction);
5157
addTransactionDOM(transaction);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /