"Cut" a variable

-3

I have this variable:

var example = AcloseBcloseCclose;

I want to separate the words divided by close and save each one in a variable.

Ex:

A close B close C close;

var a = A;

var b = B

var c = C;

How could I do this?

    
asked by anonymous 06.11.2018 / 13:21

1 answer

3

You can do this using arrays and the split method. See:

var exemplo = 'AcloseBcloseCclose';
var variaveis = exemplo.split('close');
console.log(variaveis[0], variaveis[1], variaveis[2])
    
06.11.2018 / 13:26