freeCodeCamp/curriculum/challenges/italian/02-javascript-algorithms-an.../basic-javascript/use-bracket-notation-to-fin...

1.5 KiB

id title challengeType videoUrl forumTopicId dashedName
bd7123c9c450eddfaeb5bdef Usare la notazione parentesi per trovare l'n-esimo carattere in una stringa 1 https://scrimba.com/c/cWPVJua 18343 use-bracket-notation-to-find-the-nth-character-in-a-string

--description--

Puoi usare la notazione a parentesi anche per ottenere il carattere in altre posizioni all'interno di una stringa.

Ricorda che i computer iniziano a contare da 0, quindi il primo carattere è in realtà il carattere zero.

Esempio:

const firstName = "Ada";
const secondLetterOfFirstName = firstName[1];

secondLetterOfFirstName dovrebbe acere un valore stringa d.

--instructions--

Cerchiamo di impostare thirdLetterOfLastName per eguagliare la terza lettera della variabile lastName usando la notazione parentesi.

Suggerimento: Prova a guardare l'esempio qui sopra se ti blocchi.

--hints--

La variabile thirdLetterOfLastName dovrebbe avere il valore di v.

assert(thirdLetterOfLastName === 'v');

Dovresti usare la notazione a parentesi.

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

--seed--

--after-user-code--

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

--seed-contents--

// Setup
const lastName = "Lovelace";

// Only change code below this line
const thirdLetterOfLastName = lastName; // Change this line

--solutions--

const lastName = "Lovelace";
const thirdLetterOfLastName = lastName[2];