var a = 'earthling'; console.log(a.indexOf('t')); // 'zero' based // what's the indexOf('in') ? console.log(a.charAt(4)); // what's at 4 var b = 'goodbye earthling'; var c = b.split(' ');// split returns an array console.log(c[0]); console.log(c[1]); var c = b.split('g'); console.log(c[0]);// notice that c[0] is blank console.log(c[1]); console.log(c[2]);
Output: