Page 1 of 1

Prompt section of chapter 7

Posted: Fri Jan 18, 2019 8:27 pm
by Katy
I am working on the prompt section of chapter 7 and when I typed the example code in instead of saying "Hello, Katy! You are 14 years old." The only thing it said was: "You are 14 years old." This does not make sense to me. (I tried typing it in some other ways and found when I put the code on one line and removed the semicolon in between the console ran the whole thing.)

prompt('What is your name?');
'Hello, ' + prompt('What is your name?') + '!';
'You are ' + prompt('How old are you?') + ' years old.';
"You are 14 years old."

(This is the code I saw in the book)


prompt('What is your name?');
'Hello, ' + prompt('What is your name?') + '! You are ' + prompt('How old are you?') + ' years old.';
"Hello, Katy! You are 14 years old."

(This is the code after I played with it a bit)

Re: Prompt section of chapter 7

Posted: Wed Feb 06, 2019 8:05 pm
by ᕙ(ළ෴ළ)ᕗ
You need to make the prompt a variable. Example: let promptVariable = prompt("What is your name?") and then do "hello" + promptVariable + "!".