AhmadApriliyanto23 / Berandaku

Docs
0 stars 0 forks source link

Split String | Javascript #15

Open AhmadApriliyanto23 opened 1 year ago

AhmadApriliyanto23 commented 1 year ago

const input = 'Ahmad Apriliyanto - Jakarta, Indonesia - 11 April 1998'; you have access by split with array:

const [ name, born, dateborn] = input.split('-');
console.log(name); // Ahmad Apriliyanto
console.log(born); // Jakarta, Indonesia
console.log(dateborn); //11 April 1998

or by index access

const splitInput = input.split('-');
console.log(splitInput[0]); //['Ahmad Apriliyanto']
console.log(splitInput[1]); //['Jakarta, Indonesia']
console.log(splitInput[2]); //['11 April 1998']

('-') this is separator, you have change on your problem.

Have a nice day