indexof examples c2 b6

Solutions on MaxInterview for indexof examples c2 b6 by the best coders in the world

showing results for - "indexof examples c2 b6"
Kierra
21 Feb 2016
1/*The general syntax for this method is:
2stringName.indexOf(substr);*/
3
4console.log("LaunchCode".indexOf("C"));
5
6console.log("LaunchCode".indexOf("A"));
7
8console.log("dogs and dogs and dogs!".indexOf("dog"));
9
10//6
11//-1
12//0
13
14/*An email address must contain an @ symbol. Checking for the presence 
15of this symbol is a part of email address verification in most 
16programs.*/
17
18let input = "fake.email@launchcode.org";
19let atIndex = input.indexOf("@");
20
21if (atIndex > -1) {
22   console.log("Email contains @");
23} else {
24   console.log("Invalid email");
25}
26
27//Email contains @