Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Haaste: Rakenna Lauseita JavaScriptilla | Performing Operations in JavaScript
Johdanto JavaScriptiin

book
Haaste: Rakenna Lauseita JavaScriptilla

Tehtävä

Rakennetaan kokonainen lause käyttämällä merkkijonojen yhdistämistä.

  1. Luo merkkijono "I am hungry!" käyttäen + operaattoria.

  2. Lisää sanoja välilyönneillä (paitsi ensimmäinen) käyttäen += operaattoria.

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

Tulosteen tulisi olla:

I am hungry!

Lisää sanoja välilyönneillä (esim. " 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

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 10

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

We use cookies to make your experience better!
some-alt