0

I have a string SVchnsSoQQjr5kafygOh,,,Skyrim and I'm trying to put the first 'string' into a variable, the 'Skyrim' into another variable and remove the ',,,'

I've tried .substr()

Expected output:

str = 'SVchnsSoQQjr5kafygOh,,,Skyrim'

strOne = 'SVchnsSoQQjr5kafygOh'
strTwo = 'Skyrim'
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
Kevin Malone
  • 99
  • 1
  • 11

1 Answers1

1

split is your friend

console.log('SVchnsSoQQjr5kafygOh,,,Skyrim'.split(',,,'));

To have two string variables assigned:

const foo = 'SVchnsSoQQjr5kafygOh,,,Skyrim'.split(',,,');

const [str1, str2] = foo;
console.log(str1, str2);
baao
  • 71,625
  • 17
  • 143
  • 203