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

Jquery Basics: setting a value code challenge

couldn't anderstand the perticular question "A prompt dialog will open prompting for someone's full name. Use jQuery to follow the comments in code. First, select the correct input, and then set it's value to the fullName."

my fale answer: ' ' ' //Show Prompt Window and store value var fullName = prompt("What is your full name?");

//Select Input with the id of #fullName fullName = '<p id="fullName">'fullName"</p>" //Insert value in to full name input $("#fullName").val($("#fullName").attr(fullName)); ' ' '

2 Answers

So what this challenge is asking you to do is the following:

  1. Assign the text entered into a dialog prompt to a variable.

  2. Change the value of an input to the value of that variable.

// 1. Create a variable called fullName, and then assign the value of a prompt to it 
var fullName = prompt("What is your full name?");

//2. Select the input with an id of fullName then change the value to fullName
$('#fullName').val(fullName);
Matthias Nรถrr
Matthias Nรถrr
8,614 Points

Why do you use single quotation marks?

$('#fullName')

Matthias Nรถrr, you can use either single or double quotes, it's a matter of preference, aside from when you need to escape similar quotation marks. Where I work, our standard is to always use single quotes when we can, just for the sake of consistency, so because of that I stick with single quotes. I also feel like at least in my personal opinion they are easier to parse visually.

thank you very much!