Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Build Sentences with JavaScript | Performing Operations in JavaScript
Introduction to JavaScript
course content

Kursinnehåll

Introduction to JavaScript

Introduction to JavaScript

1. JavaScript Fundamentals
2. Variables and Data Types in JavaScript
3. Performing Operations in JavaScript
4. Controlling Program Flow with Conditional Statements
5. Looping Through Data in JavaScript
6. Functions in JavaScript

book
Challenge: Build Sentences with JavaScript

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.
12345678
let sentence = ""; sentence += "___"; // "I" sentence += "___"; // "I am" sentence += "___"; // "I am hungry" sentence += "___"; // "I am hungry!" console.log(sentence);
copy

The output should be:

python

Add words with spaces (e.g., " am"" hungry").

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

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 10
Vi beklagar att något gick fel. Vad hände?
some-alt