Issue
I am currently iterating through an array and adding the key to my panels array. I am getting the correct length of the array which is three but my parseint is displaying NaN. How can I convert the key which is a string to an int to display panel-0 for example instead of panel-NaN.
Object.keys(this.Category).forEach((key) => {
this.panels.push(parseInt(key, 3));
this.activeIds = this.panels.map(p => 'panel-' + p);
});```
Solution
what you are doing is parseInt('Car' 3)
, since "Car" is not a number you will get NaN
probaby you want something like this:
Object.keys(this.Category).forEach((key) => {
this.panels.push('panel-' + panels.length + 1);
});
Answered By - Zerotwelve
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.