File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,38 @@ function calculateTotal() {
1111 const billValue = billInput . value ;
1212 const tipValue = tipInput . value ;
1313 const splitValue = splitInput . value ;
14+ if ( billValue < 0 && tipValue < 0 && splitValue < 0 )
15+ {
16+ alert ( "Invalid : Please Enter positive bill amount , tip percentage and split value!" ) ;
17+ return ;
18+ }
19+ if ( billValue < 0 && tipValue < 0 )
20+ {
21+ alert ( "Invalid : Please enter positive bill amount and tip percentage!" ) ;
22+ return ;
23+ }
24+ if ( billValue < 0 && splitValue < 0 )
25+ {
26+ alert ( "Invalid : Please enter positive bill amount and split value!" ) ;
27+ return ;
28+ }
29+ if ( splitValue < 0 && tipValue < 0 )
30+ {
31+ alert ( "Invalid : Please enter positive tip percentage and split value!" ) ;
32+ return ;
33+ }
34+ if ( billValue < 0 ) {
35+ alert ( "Invalid : Please enter positive bill amount!" ) ;
36+ return ;
37+ }
38+ if ( tipValue < 0 ) {
39+ alert ( "Invalid : Please enter positive tip percentage!" ) ;
40+ return ;
41+ }
42+ if ( splitValue < 0 ) {
43+ alert ( "Invalid : Please enter positive split value!" ) ;
44+ return ;
45+ }
1446
1547 const tipAmount = billValue * ( tipValue / 100 ) ;
1648 const totalValue = parseFloat ( billValue ) + tipAmount ;
You can’t perform that action at this time.
0 commit comments