Javascript String Sub String via indexOf

Description

Javascript String Sub String via indexOf

let sentence = "A list of items: cherries, oranges, apples, bananas.";
let start = sentence.indexOf(":");
let end = sentence.indexOf(".", start+1);

let list = sentence.substring(start+1, end);
console.log(list);/* ww  w.ja  va 2s  .  c o m*/



PreviousNext

Related