Haaste: Rakenna Lauseita JavaScriptilla
Tehtävä
Rakennetaan kokonainen lause käyttämällä merkkijonojen yhdistämistä.
Luo merkkijono
"I am hungry!"
käyttäen+
operaattoria.Lisää sanoja välilyönneillä (paitsi ensimmäinen) käyttäen
+=
operaattoria.
9
1
2
3
4
5
6
7
8
let sentence = "";
sentence += "___"; // "I"
sentence += "___"; // "I am"
sentence += "___"; // "I am hungry"
sentence += "___"; // "I am hungry!"
console.log(sentence);
12345678let sentence = ""; sentence += "___"; // "I" sentence += "___"; // "I am" sentence += "___"; // "I am hungry" sentence += "___"; // "I am hungry!" console.log(sentence);
Tulosteen tulisi olla:
I am hungry!
Lisää sanoja välilyönneillä (esim. " am"
, " hungry"
).
9
1
2
3
4
5
6
7
8
let sentence = "";
sentence += "I"; // "I"
sentence += " am"; // "I am"
sentence += " hungry"; // "I am hungry"
sentence += "!"; // "I am hungry!"
console.log(sentence);
12345678let sentence = ""; sentence += "I"; // "I" sentence += " am"; // "I am" sentence += " hungry"; // "I am hungry" sentence += "!"; // "I am hungry!" console.log(sentence);
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 10
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme