Welcome to Lesson 3.16


#1

This category is for all discussion related to lesson 3.16. There are threads already started for sharing resources, talking about assessments, and general discussion about the lesson, but please feel free to start a new thread about the lesson if your topic isn’t captured already!


#2

Question: I am working through the lesson and trying to use the \n newline string but it’s not working. Am I using it incorrectly? I’m not getting an error and it runs all of the text on 1 line.

setText(“gameArea”, (((“Learning to drive is a tricky process.\n”)+
(“There are a few rules you must follow.\n\n”))+
(“1. Keep two \n”)+getText(“pluralNoun”)+("on the “))+(“steering wheel at all times.”)+
(“2. Step on the " + getText(“noun1”)+” to speed up and the “+getText(“noun2”)+” to slow down.\n”));
});


#3

@tschlotterback Can you share your project that you are doing this work in? It would be easier to look at it that way.

My guess is that your parens don’t match up. You don’t need parens around everything. Also there is a } in there that doesn’t seem to go to anything.

Below is this without the extra parens and curly brace.

setText(“gameArea”, “Learning to drive is a tricky process.\n”+ “There are a few rules you must follow.\n\n”+
“1. Keep two \n”+getText(“pluralNoun”)+"on the “+“steering wheel at all times.”+
“2. Step on the " + getText(“noun1”)+” to speed up and the “+getText(“noun2”)+” to slow down.\n”);

-Dani


#4

onEvent(“nextScreen”, “click”, function() {
setScreen(“game”);
var noun1 = getText(“noun1”);
var pluralNoun = getText(“pluralNoun”);
var noun2 = getText(“noun2”);
var verb = getText(“verb”);
var song = getText(“song”);
setText(“gameArea”,(“Learning to drive is a tricky process.\n”)+
(“There are a few rules you must follow.\n\n”)+
(“1. Keep two \n”)+pluralNoun+(" on the steering wheel at all times.\n")+
(“2. Step on the “+noun1+” to speed up and the “+noun2+” to slow down.\n”)+
(“3. Your parents will just LOVE it if you play “+song.toUpperCase()+” on the radio.\n”)+
("4. Make sure to honk your horn when you see “+verb+ " on a street sign. \n”));
});
onEvent(“playAgain”, “click”, function() {
setScreen(“home”);
setText(“pluralNoun”, “”);
setText(“noun1”, “”);
setText(“noun2”, “”);
setText(“song”, “”);
setText(“verb”, “”);
});


#5

HI @tschlotterback

Did you try the updated line of code I sent? If you have and its still not working can you click the share button at the top of the window in code studio and share the link to the project itself?

Thanks!

Dani


#6

#7

@tschlotterback

Finally figured it out! I had to ask for another set of eyes so don’t feel bad this is tricky. You are using a text input for displaying your output instead of text area. If you use a text area it should work just fine!

-Dani