Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics Working with Strings Variables and Strings Challenge Solution

paragraph is not showing up on the browser. checked the .js links and everything is fine. no error in the console.

// const firstName = prompt("type first name"); const lastname = prompt("type last name"); const sentence= <p>your first name is ${firstName} and you last name is ${lastname}</p>; Document.querySelector('main').innerHTML= sentence;

2 Answers

devin blair
devin blair
4,955 Points

First problem is I think you commented out your vars. // const firstName = prompt("type first name"); const lastname = prompt("type last name");.

const firstName = prompt("type first name"); const lastname = prompt("type last name");

The second is you missed the backticks in your sentence var it should be const sentence = `<p>your first name is ${firstName} and you last name is ${lastname}.</p>`;

and lastly, you just need to change the uppercase d in Doucment.querySelector to a lowercase d

I wish I could explain the backticks part more but im a beginner as well there's some docs on template literals on MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals Hope you found your answer :)

all together it will look like

const firstName = prompt("type first name");
const lastname = prompt("type last name");

const sentence = `<p>your first name is ${firstName} and you last name is ${lastname}.</p>`;
docuemnt.querySelector('main').innerHTML = sentence;

I believe Document should be in lowercase. Also did you comment out const firstName = prompt("type first name");? I noticed the //.