1 00:00:00,000 --> 00:00:09,738 [MUSIC] 2 00:00:09,738 --> 00:00:13,724 One of the benefits of JavaScript is that it allows us to build websites and 3 00:00:13,724 --> 00:00:16,950 applications that people can interact with. 4 00:00:16,950 --> 00:00:21,426 This interaction is often in the form of user input, like entering words or 5 00:00:21,426 --> 00:00:24,340 other characters into a web form. 6 00:00:24,340 --> 00:00:28,930 As a JavaScript developer, you will often work with this user input. 7 00:00:28,930 --> 00:00:32,339 For example, you might have to remove whitespace or search for 8 00:00:32,339 --> 00:00:34,590 values within user input. 9 00:00:34,590 --> 00:00:36,777 When it comes to storing user input, 10 00:00:36,777 --> 00:00:40,750 JavaScript commonly relies on the string data type. 11 00:00:40,750 --> 00:00:44,336 The string type Describes variables made up of letters and 12 00:00:44,336 --> 00:00:48,080 other sequences of characters wrapped in quotation marks. 13 00:00:49,160 --> 00:00:53,730 Strings can include not only letters, but also numbers and symbols. 14 00:00:54,830 --> 00:00:58,040 strings in JavaScript are said to be immutable. 15 00:00:58,040 --> 00:01:00,500 This means they can't be altered or updated. 16 00:01:01,540 --> 00:01:07,125 JavaScript treats the string similar to an object, providing properties and 17 00:01:07,125 --> 00:01:13,170 built in methods that allow us to access and manipulate string values. 18 00:01:13,170 --> 00:01:17,064 These methods can't change the value of a string once it's defined, 19 00:01:17,064 --> 00:01:20,980 but instead, return a completely new string object. 20 00:01:20,980 --> 00:01:23,359 Let's open up the console and give this a try. 21 00:01:25,454 --> 00:01:28,630 We'll take the familiar to uppercase method and 22 00:01:28,630 --> 00:01:33,130 apply on a variable named state, that stores the string California. 23 00:01:34,990 --> 00:01:36,753 We'll first define the variable 24 00:01:46,369 --> 00:01:49,260 We'll need to make sure that all the letters are lowercase. 25 00:01:50,450 --> 00:01:53,724 Now we'll apply the two uppercase method to the state variable. 26 00:02:00,867 --> 00:02:05,171 We see CALIFORNIA in all capital letters. 27 00:02:05,171 --> 00:02:11,110 But when we check the value of state again, it's still in all lowercase. 28 00:02:12,540 --> 00:02:14,933 String methods take the value of a string and 29 00:02:14,933 --> 00:02:17,400 output values based on the selected method. 30 00:02:18,450 --> 00:02:25,320 With string methods, we use the format string dot methodName, parentheses. 31 00:02:25,320 --> 00:02:28,700 Many of these string methods take an index value as a parameter. 32 00:02:29,860 --> 00:02:34,721 Like with arrays, bracket notation allows us to access string characters using 33 00:02:34,721 --> 00:02:36,730 index values that start at zero. 34 00:02:37,760 --> 00:02:38,861 For instance, 35 00:02:38,861 --> 00:02:43,861 we can access the third character of a string using bracket notation by 36 00:02:43,861 --> 00:02:49,640 passing in the number two to access the item at index two using bracket notation. 37 00:02:50,950 --> 00:02:55,000 Access the character at zero of our state variable. 38 00:02:55,000 --> 00:02:56,386 The console will log out C. 39 00:03:07,475 --> 00:03:08,321 Nice. 40 00:03:08,321 --> 00:03:11,320 Coming up, we'll explore two groups of methods. 41 00:03:12,320 --> 00:03:16,060 Those for searching a string and methods for modifying a string value.