Prompt section of chapter 7

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Prompt section of chapter 7

Re: Prompt section of chapter 7

by ᕙ(ළ෴ළ)ᕗ » Wed Feb 06, 2019 8:05 pm

You need to make the prompt a variable. Example: let promptVariable = prompt("What is your name?") and then do "hello" + promptVariable + "!".

Prompt section of chapter 7

by Katy » Fri Jan 18, 2019 8:27 pm

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)

Top