Files
freeCodeCamp/curriculum/challenges/italian/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md

1.8 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244b7 Concatenare le stringhe con l'operatore + 1 https://scrimba.com/c/cNpM8AN 16802 concatenating-strings-with-plus-operator

--description--

In JavaScript, quando l'operatore + viene usato con un valore di tipo String, questo prende il nome di operatore di concatenazione. Puoi costruire una nuova stringa da altre stringhe concatenandole insieme.

Esempio

'My name is Alan,' + ' I concatenate.'

Nota: Attenzione agli spazi. La concatenazione non aggiunge spazi tra le stringhe concatenate, quindi dovrai aggiungerli tu stesso.

Esempio:

var ourStr = "I come first. " + "I come second.";

La stringa I come first. I come second. sarebbe visualizzata nella console.

--instructions--

Costruisci myStr dalle stringhe This is the start. e This is the end. usando l'operatore +. Assicurati di includere uno spazio tra le due stringhe.

--hints--

myStr dovrebbe avere un valore stringa This is the start. This is the end.

assert(myStr === 'This is the start. This is the end.');

Dovresti usare l'operatore + per costruire myStr.

assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));

myStr dovrebbe essere creato usando la parola chiave var.

assert(/var\s+myStr/.test(code));

Dovresti assegnare il risultato alla variabile myStr.

assert(/myStr\s*=/.test(code));

--seed--

--after-user-code--

(function(){
  if(typeof myStr === 'string') {
    return 'myStr = "' + myStr + '"';
  } else {
    return 'myStr is not a string';
  }
})();

--seed-contents--

var myStr; // Change this line

--solutions--

var myStr = "This is the start. " + "This is the end.";