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

How do I get I allow any name to be accepted in JS?

I'm sorry if this is a dumb question, but I want to be able to have anyone enter their name and it be accepted without returning an undefined.

I know that I have to declare it first like: let name = (but I don't know what to put here)

And I partially know how to retrieve it: ${name}

I can't find where the video is teaching this topic, any help would be greatly appreciated.

1 Answer

Mark Casavantes
Mark Casavantes
2,880 Points

Good Morning Deanna,

Welcome to Team Treehouse!

There are no dumb questions. Everyone starts out knowing nothing.

There are several of us who seek out students who need help. Keep posting your questions Deanna.

Similar to what you wrote before would work, just change guess to name.

const guess = prompt("Guess a number between 1 and 10.");
let name = prompt("Please enter your name");

// You also can write 
let name = "Deanna";

May I make a few suggestions? Click on "Markdown Cheatsheet" at the bottom of this page on how to post your code into this Community.

Use codepen.io to develop your code. You can enter HTML, CSS and JavaScript into codepen.io. If you see a red circle with an exclamation point in it, click on it. Codepen.io will give you the line and space where it thinks your error is. It is not perfect. Sometimes your error is before where it detects your error.

Put your code in jslint.com and it will evaluate your code.

If you write any HTML, you can use https://validator.w3.org/

If you write any CSS, you can use http://jigsaw.w3.org/css-validator/

If you seek extra practice with your JavaScript, use https://edabit.com There are other related programs such as Codecademy, Topcoder, HackerEarth, ProjectEuler, CodeChef etc...

If you enjoy games to learn more JavaScript, use https://www.codingame.com/

All my recommended websites are free.

I hope this is helpful to you.

When you can, help others.

Thank you,

Mark