HELP! Simple function(JavaScript), can’t output variables. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HELP! Simple function(JavaScript), can’t output variables.

Function message(){ Let name = prompt(‘Enter your name.’); Let vacation = prompt(‘what is your favorite vacation spot?’); document.write(‘ ${name}, you love to travel to ${vacation}’); } Message(); //=======BROWSER======== ${name}, you love to travel to ${vacation} // it’s not outputting my variables. What am I doing wrong?

10th Mar 2021, 3:20 AM
Nirvashtypezero
Nirvashtypezero - avatar
2 Answers
+ 3
you are using single quotes where template string must be enclosed by backticks (`): document.write(`${name}, you love to travel to ${vacation}`);
10th Mar 2021, 3:32 AM
visph
visph - avatar
0
visph thank you so much for that. that clearied it up for me!!!
10th Mar 2021, 3:36 AM
Nirvashtypezero
Nirvashtypezero - avatar