-1

I want to create an Array from strings

That is how the string is formatted

const someString = "a,b,c,d";

And I need an Array like this

const someArray = ["a", "b", "c", "d"];
Stophface
  • 8,519
  • 25
  • 87
  • 179

2 Answers2

1

Use String.prototype.split()

const someString = "a,b,c,d";
const someArray = someString.split(',');

MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split

Chiffie
  • 533
  • 3
  • 18
1

You can simply split the string:

const arr = "a,b,c,d".split(",")

Sam L
  • 173
  • 9