Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Sfida: Costruisci Frasi con JavaScript | Eseguire Operazioni in JavaScript
Introduzione a JavaScript

book
Sfida: Costruisci Frasi con JavaScript

Compito

Costruiamo una frase completa usando la concatenazione di stringhe.

  1. Crea la stringa "I am hungry!" utilizzando l'operatore +.

  2. Aggiungi parole con spazi (eccetto la prima) utilizzando l'operatore +=.

let sentence = "";

sentence += "___"; // "I"
sentence += "___"; // "I am"
sentence += "___"; // "I am hungry"
sentence += "___"; // "I am hungry!"

console.log(sentence);
12345678
let sentence = ""; sentence += "___"; // "I" sentence += "___"; // "I am" sentence += "___"; // "I am hungry" sentence += "___"; // "I am hungry!" console.log(sentence);
copy

L'output dovrebbe essere:

I am hungry!

Aggiungi parole con spazi (ad esempio, " am", " hungry").

let sentence = "";

sentence += "I"; // "I"
sentence += " am"; // "I am"
sentence += " hungry"; // "I am hungry"
sentence += "!"; // "I am hungry!"

console.log(sentence);
12345678
let sentence = ""; sentence += "I"; // "I" sentence += " am"; // "I am" sentence += " hungry"; // "I am hungry" sentence += "!"; // "I am hungry!" console.log(sentence);
copy

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 10

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

some-alt