Files
freeCodeCamp/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string.md
camperbot b3af21d50f chore(i18n,curriculum): update translations (#42487)
* chore(i18n,curriculum): update translations

* chore: Italian to italian

Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
2021-06-14 11:34:20 -07:00

1.8 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bd7123c9c549eddfaeb5bdef Usare la notazione a parentesi per trovare il primo carattere in una stringa 1 https://scrimba.com/c/ca8JwhW 18341 use-bracket-notation-to-find-the-first-character-in-a-string

--description--

La notazione a parentesi è un modo per ottenere il carattere a un indice specifico all'interno di una stringa.

La maggior parte dei moderni linguaggi di programmazione, come JavaScript, non inizia a contare da 1 come gli esseri umani. Loro iniziano dallo 0. Questo è indicato come indicizzazione Zero-based.

Ad esempio, il carattere all'indice 0 nella parola Charles è C. Quindi, se var firstName = "Charles", è possibile ottenere il valore della prima lettera della stringa utilizzando firstName[0].

Esempio:

var firstName = "Charles";
var firstLetter = firstName[0];

firstLetter dovrebbe avere un valore stringa C.

--instructions--

Usa la notazione parentesi per trovare il primo carattere nella variabile lastName e assegnala a firstLetterOfLastName.

Suggerimento: Prova a guardare l'esempio qui sopra se sei bloccato.

--hints--

La variabile firstLetterOfLastName dovrebbe avere il valore di L.

assert(firstLetterOfLastName === 'L');

Dovresti usare la notazione a parentesi.

assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/));

--seed--

--after-user-code--

(function(v){return v;})(firstLetterOfLastName);

--seed-contents--

// Setup
var firstLetterOfLastName = "";
var lastName = "Lovelace";

// Only change code below this line
firstLetterOfLastName = lastName; // Change this line

--solutions--

var firstLetterOfLastName = "";
var lastName = "Lovelace";

// Only change code below this line
firstLetterOfLastName = lastName[0];