-4

I have a value

sections = "12A,13B,14C"

But I need [12A, 13B, 14C] for future use. How to create array from above string?

Mohammad Usman
  • 34,173
  • 19
  • 88
  • 85
ashishdudhat
  • 178
  • 3
  • 9

2 Answers2

2

You have to use split method for that to split your string data into array values, have a look to updated code

  var sections = "12A,13B,14C";
  sections = sections.split(',');
  console.log(sections);
0

Hope this will help! Just use split method of JS.

  sections = "12A,13B,14C"
  let array = sections.split(',');
  console.log(array)
Harsh Patel
  • 5,503
  • 7
  • 33
  • 62