Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Strings 3/5 | Data Types and Variables
Introduction to JavaScript (staging)
course content

Course Content

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

Strings 3/5

Accessing Character:

We can also access different characters from a string variable, and for that, we use the square brackets []. The syntaxes for accessing characters are str.charAt(pos) and variableName(pos) where pos is the position or index of the character that we want to access and variableName is the variable to be sliced. Let’s look at an example.

123
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
copy

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 21
toggle bottom row

Strings 3/5

Accessing Character:

We can also access different characters from a string variable, and for that, we use the square brackets []. The syntaxes for accessing characters are str.charAt(pos) and variableName(pos) where pos is the position or index of the character that we want to access and variableName is the variable to be sliced. Let’s look at an example.

123
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
copy

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 3. Chapter 21
toggle bottom row

Strings 3/5

Accessing Character:

We can also access different characters from a string variable, and for that, we use the square brackets []. The syntaxes for accessing characters are str.charAt(pos) and variableName(pos) where pos is the position or index of the character that we want to access and variableName is the variable to be sliced. Let’s look at an example.

123
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
copy

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Accessing Character:

We can also access different characters from a string variable, and for that, we use the square brackets []. The syntaxes for accessing characters are str.charAt(pos) and variableName(pos) where pos is the position or index of the character that we want to access and variableName is the variable to be sliced. Let’s look at an example.

123
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
copy

Task

A string value, England, is stored in a variable named country. The task is to display the letter a of the variable England.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 3. Chapter 21
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt