Conteúdo do Curso
Introduction to JavaScript
Introduction to JavaScript
Challenge: Sentence Building
Task
Let's build a full sentence using string concatenation.
- Create the string
"I am hungry!"
using the+
operator. - Add words with spaces (except the first one) using the
+=
operator.
let sentence = ""; sentence += "___"; // "I" sentence += "___"; // "I am" sentence += "___"; // "I am hungry" sentence += "___"; // "I am hungry!" console.log(sentence);
The output should be:
Add words with spaces (e.g., " am"
, " hungry"
).
let sentence = ""; sentence += "I"; // "I" sentence += " am"; // "I am" sentence += " hungry"; // "I am hungry" sentence += "!"; // "I am hungry!" console.log(sentence);
Obrigado pelo seu feedback!