Challenge: Build Sentences with JavaScript
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.
12345678let sentence = ""; sentence += "___"; // "I" sentence += "___"; // "I am" sentence += "___"; // "I am hungry" sentence += "___"; // "I am hungry!" console.log(sentence);
The output should be:
I am hungry!
Add words with spaces (e.g.,Β " am"
,Β " hungry"
).
12345678let sentence = ""; sentence += "I"; // "I" sentence += " am"; // "I am" sentence += " hungry"; // "I am hungry" sentence += "!"; // "I am hungry!" console.log(sentence);
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 10
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 2.33
Challenge: Build Sentences with JavaScript
Swipe to show menu
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.
12345678let sentence = ""; sentence += "___"; // "I" sentence += "___"; // "I am" sentence += "___"; // "I am hungry" sentence += "___"; // "I am hungry!" console.log(sentence);
The output should be:
I am hungry!
Add words with spaces (e.g.,Β " am"
,Β " hungry"
).
12345678let sentence = ""; sentence += "I"; // "I" sentence += " am"; // "I am" sentence += " hungry"; // "I am hungry" sentence += "!"; // "I am hungry!" console.log(sentence);
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 10