Commit 4bd7f716 authored by 李彥志's avatar 李彥志

update totalPrice() (change const to let & remove :void

parent ee30fbfc
...@@ -22,14 +22,14 @@ export class P2Component implements OnInit { ...@@ -22,14 +22,14 @@ export class P2Component implements OnInit {
message = ''; message = '';
buildMessage(): void { // buildMessage(): void {
if (this.name !== null && this.price !== null && this.quantity !== null && // if (this.name !== null && this.price !== null && this.quantity !== null &&
this.name !== undefined && this.price !== undefined && this.quantity !== undefined // this.name !== undefined && this.price !== undefined && this.quantity !== undefined
) { // ) {
this.message = '你購買' + this.name + '商品,單價' + this.price + '元,數量' // this.message = '你購買' + this.name + '商品,單價' + this.price + '元,數量'
+ this.quantity + '元,共計NT$'; // + this.quantity + '元,共計NT$';
} // }
} // }
addData(): void { addData(): void {
...@@ -48,10 +48,10 @@ export class P2Component implements OnInit { ...@@ -48,10 +48,10 @@ export class P2Component implements OnInit {
} }
totalPrice(): void { totalPrice() {
const result = 0; let result = 0;
for ( for (
const i = 0; i < this.datas.length; i++ let i = 0; i < this.datas.length; i++
) { const data = this.datas[i]; ) { const data = this.datas[i];
result = result + data.total; result = result + data.total;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment