the task is to make a function that gives serial number to every new product so the new serial would concat the barcode with the serial but if the number is 10 it should shift to 11 (last digit zero not allowed) so the serial should be 1,2....9,11,12..19,21,22 but the product is 1,2,...11,11,12...21,21,22 I don't know why. sorry in advance if the reason is silly. that is the code:
barcode = '56734';
ary: string[] = [];
serial!: number;
finaly!: string;
newy(){
if (this.ary.length == 0){
this.serial = 1
}else if((this.ary.length + 1) %10 == 0){
this.serial = this.ary.length + 2
} else {
this.serial = this.ary.length + 1
}
this.finaly = this.barcode + this.serial;
this.ary.push(this.finaly)
return this.ary
}