var input = 'john smith~123 Street~Apt 4~New York~NY~12345';
var fields = input.split('~');
var name = fields[0];
var street = fields[1];
var str= "12344A56789";
var splitted = str.split('4A'); //this will output ["1234", "56789"]
var first = splitted[0]; //"1234"
var second = splitted[1]; //"56789"
console.log('First is: ' + first + ', and second is: ' + second);
let str = "Learning to code";
// slice from index 2 to end
let str1 = str.slice(2);
console.log(str1);
// slice from index 1 to index 8
let str2 = str.slice(1, 8);
console.log(str2);
// slice from index 5 to index (str.length - 3)
let str3 = str.slice(5, -3);
console.log(str3);
// slice from index 100 to end (returns '')
let str4 = str.slice(100);
console.log(str4);
// slice from index 0 to end of string
let str5 = str.slice(0);
console.log(str5);