I am new to javascript and i am trying to divide and store a part of a string
this.chartIdSelector="Bulletsavings-140"
this.opportunityId = +this.chartIdSelector.substring(this.chartIdSelector.lastIndexOf('-') + +1);
This returns 140 back but if i include any alphabet it returns NAN
this.chartIdSelector="Bulletsavings-14av0"
this.opportunityId = +this.chartIdSelector.substring(this.chartIdSelector.lastIndexOf('-') + +1);
NAN
+from+this.chartIdSelector+) will try to convert the final value to a number. Since in the second example the final value contains a character, it will returnNaN(Not a Number)