course content

Course Content

Introduction to JavaScript

Challenge: Sentence BuildingChallenge: Sentence Building

Task

Let's build a full sentence using string concatenation.

  1. Create the string "I am hungry!" using the + operator.
  2. Add words with spaces (except the first one) using the += operator.

The output should be:

1. 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);
      

Everything was clear?

Section 3. Chapter 10