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?
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?
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])