We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32d4b1d commit 9c15c48Copy full SHA for 9c15c48
067-expense tracker/script.js
@@ -39,13 +39,19 @@ function generateID() {
39
40
function addTransaction(e) {
41
e.preventDefault();
42
- if (text.value.trim() === "" || amount.value.trim() === "") {
+ const amountValue = Number(amount.value);
43
+ if (
44
+ text.value.trim() === "" ||
45
+ isNaN(amountValue) ||
46
+ amount.value.trim() === ""
47
+ ) {
48
showNotification();
49
+ return;
50
} else {
51
const transaction = {
52
id: generateID(),
53
text: text.value,
- amount: +amount.value,
54
+ amount: amountValue,
55
};
56
transactions.push(transaction);
57
addTransactionDOM(transaction);
0 commit comments