Advertisement
Guest User

ArturG

a guest
Feb 18th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 'The index of the 2nd "' + searchTerm + '" is ' + paragraph.indexOf(searchTerm, (indexOfFirst + 1));
  2. function findZip(str) {
  3.     const paragraph = str;
  4.     const searchTerm = 'zip';
  5.     const indexOfFirst = paragraph.indexOf(searchTerm);
  6.     return str + 'The index of the 2nd "' + searchTerm + '" is ' + paragraph.indexOf(searchTerm, (indexOfFirst + 1));
  7. }
  8. console.log(findZip("all zip files are zipped")); // ➞ 18
  9. console.log(findZip("all zip files are compressed")); // ➞ -1
  10. console.log(findZip("all zip files are zipped")); //  18)
  11. console.log(findZip("all zip files are compressed")); // -1)
  12. console.log(findZip("We believe university-level zip education can be both high quality and low cost. Using the economics of the Internet, we've connected some of the greatest teachers to hundreds of thousands of students all over the world.")); // -1)
  13. console.log(findZip("Zip is a file format used for data compression and archiving. A zip file contains one or more files that have been compressed, to reduce file size, or stored as is. The zip file format permits a number of compression algorithms."));
  14. // 169
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement