-4

I have a string like below.

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

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

ashishdudhat
  • 180
  • 3
  • 9

2 Answers2

3

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);
1

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

  sections = "12A,13B,14C"
  let array = sections.split(',');
  console.log(array)
Harsh Patel
  • 6,334
  • 10
  • 40
  • 73