Lab 2: Parse a String
-
Parse the following string
-
In bold, print the field name. Then, print the field value.
-
Copy-paste the string into your JavaScript. Assign it to a variable,
called parseString.
-
The '*' separates each piece of data.
-
Field Order: name, bearcat ID, e-mail, phone number
Spiff Goodman*goodmansm*goodmansm@uc.edu*556-3278
-
Handy methods:
-
parseString.substring(beginindex, endindex) to take out part of
the string
-
parseString.charAt(character) to find the location of a character
-
parseString.charAt(character, beginIndex) to find the location of
a character after the beginIndex.
-
document.write() to print each element on a separate line. Don't
forget to use the <br> tag.
-
+ to combine the Strings you are printing.
-
Slide about substrings: substring
methods
-
Hint: Save the value of the charAt() method to a variable.
Use that method with substring() to find a field. Then, use that
same variable as the beginIndex value in the next charAt() method to find
the next occurrence of the asterisk.
-
Need Help?
-
Advanced: if you have time
Conditions
Home
Internet II: Day 3