0

I get one string by query like '5e6,5e4,123'.
And I want to make an array containing this query as below in JS.

['5e6', '5e4', '123']

How can I make this? Thank you so much for reading it.

Joundill
  • 6,828
  • 12
  • 36
  • 50
Thomas Jason
  • 538
  • 2
  • 7
  • 18

5 Answers5

1

You can use .split(',')

var str = "5e6,5e4,123";
var array = str.split(',');

console.log(array);

You can read more on this here

Hisham Bawa
  • 438
  • 5
  • 14
0

Use String.split:

console.log('5e6,5e4,123'.split(","))
Marco
  • 7,007
  • 2
  • 19
  • 49
0

You can make use of split method of string like below:

var res = str.split(',');

Joundill
  • 6,828
  • 12
  • 36
  • 50
Harmandeep Singh Kalsi
  • 3,315
  • 2
  • 14
  • 26
0
 var query = '5e6,5e4,123';
 var queries = query.split(‘,’);
tbone849
  • 925
  • 8
  • 18
-1
const output = input.split(',');
Evert
  • 93,428
  • 18
  • 118
  • 189