0

I'm trying to remove double quotes from a string so it becomes like a number but i'm finding it hard to do.

 for ( let i = 0 ; i < this.advanceSaveList.length; i++) {
    if (this.advanceSaveList) {
    this.advanceSearchSelectedGrades = [this.advanceSaveList[i].properties.gradeIds.replace (/"/g,'')];

  }

With the code above the results returns like ["58,59"] but i want it to return like [58, 59]

neiza
  • 265
  • 4
  • 15
  • Possible duplicate of [javascript split string to array of int](https://stackoverflow.com/questions/8232776/javascript-split-string-to-array-of-int) – Cid Oct 14 '19 at 12:32
  • Why are you use an if condition? – Amir Makram Oct 14 '19 at 12:33
  • So is `gradeIds` a nested array? – silencedogood Oct 14 '19 at 12:38
  • 1
    Does the string *have* double quotes in it? Or are you looking at the *string representation*? A string of `"hello world"` may have double quotes when printed in the console to denote it's a string, in reality the *content* of it is `hello world` - 11 characters. – VLAZ Oct 14 '19 at 12:38
  • @silencedogood, yes its a nested array – neiza Oct 14 '19 at 12:39
  • If you have a string that contains *a number*, you can parse it and obtain the number. – VLAZ Oct 14 '19 at 12:39
  • @Cid, the link you provide returns the results with double quotes, so it doesn't solve my issue – neiza Oct 14 '19 at 12:40
  • 1
    `"58,59".split(',').map( Number );` gives `[58, 59]` as output. no double quotes. – Cid Oct 14 '19 at 12:42

0 Answers0