Contenido del Curso
Introduction to JavaScript (staging)
Introduction to JavaScript (staging)
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.
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
Tarea
A string value, England
, is stored in a variable named country
. The task is to display the letter a
of the variable England
.
¡Gracias por tus comentarios!
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.
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
Tarea
A string value, England
, is stored in a variable named country
. The task is to display the letter a
of the variable England
.
¡Gracias por tus comentarios!
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.
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
Tarea
A string value, England
, is stored in a variable named country
. The task is to display the letter a
of the variable England
.
¡Gracias por tus comentarios!
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.
let str = 'JavaScript'; console.log(str[0] ); console.log( str.charAt(4));
Tarea
A string value, England
, is stored in a variable named country
. The task is to display the letter a
of the variable England
.