> For the complete documentation index, see [llms.txt](https://eleven-fifty-academy.gitbook.io/javascript-100-prework-gitbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eleven-fifty-academy.gitbook.io/javascript-100-prework-gitbook/javascript-library/0-prework/4-js-basics/strings.md).

# strings

In this module we'll discuss strings.

## Description

Strings are used in every application that you'll ever use, usernames, passwords, lists of products, and anything else that will have a plain English value(other languages too). Strings are a group of characters "strung" (concatenated/added) together. Strings must go in quotes.

## File Location

You should be located in the following file:

```
   javascript-library
        └── 0-PreWork
            └── 1-HTML-Basics
            └── 2-CSS-Basics
            └── 3-JavaScript-Basics
                03-strings.js       <---- this file in this module.
```

## String Examples

Let's print a few strings to the console:

```javascript
console.log("I was born in Indianapolis.");
console.log("I've lived in three states.");
console.log("I like Indiana the best.");
console.log("My bank account had two million bucks in it. It's gone now.");
```

## Variables

Just like integers, we need the var keyword(or const or let) to hold the value in a container. Here are a few examples:

```javascript
var tweet = "Lebron is king! Westbrook for president!";
var facebookPost = "Just thought I'd share this goofy video of my dog eating our couch.";
var username = 'jamespauloconnor';
```

## Numbers in a String

You can use numbers in a string, but you won't be able to do math operations. Numbers in quotes are treated as text.

```javascript
var password = "123456789HELLO";
var birthDay = "August 11";
```

## Concatenation

Concatenating happens when we add 2 strings together.

```javascript
var birthCity = "Indianapolis ";
var birthState = "Indiana";

console.log(birthCity + ", " + birthState);
```

## Challenge

QUICK CHALLENGE: See if you can print your own birth city and birth state to the console. What would you have to do?

## Strings and Numbers

We can mix strings and integers together.

```javascript
var ageInAugust = 40; 
var highSchool = "Bill Murray High School";
var graduatedHighSchool = 1994;

console.log(highSchool + commaWithSpace + graduatedHighSchool);
console.log("My age in August:", ageInAugust);
```

## Another Challenge:

Write a string that has two variables. Output I graduated from Bill Murray High School in 1994.

```javascript
var gradYear = 1994;
var highSchool = "Bill Murray High School";

console.log("I graduated from " + highSchool + " in " + gradYear + ".");
```

## String Methods

String Methods allow us to introduce functions w/o having to worry about writing them. In JS, Strings, Numbers, and Booleans (not yet covered) have some built in properties and methods that are available through using the `.` operator.

We'll talk more about this in the future, but here are a few items to get you familiar with the syntax:

```javascript
//length - returns the length of a string (including spaces)
console.log(highSchool.length); 

//lower or upper case
console.log(highSchool.toUpperCase()); //BILL MURRAY HIGH SCHOOL
console.log(highSchool.toLowerCase()); //bill murray high school

console.log(highSchool.split(" ")); //splits the string into an array on each space['Bill', 'Murray', 'High', 'School' ]
console.log(highSchool.slice(10)); // cuts off everything before the nth index
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eleven-fifty-academy.gitbook.io/javascript-100-prework-gitbook/javascript-library/0-prework/4-js-basics/strings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
