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 trialwilliamrossi
6,232 Pointsjavascript basics
Create a variable named fullName that combines both the first and last name variables to create a string like "Mary Jones".
var firstName = "will"; var lastName = "jones"; var fullName = (firstName ' ' + lastName); document.write (fullName);
What am I doing wrong? :(
8 Answers
John Norris
21,145 PointsThis is the correct answer
var firstName = 'Will';
lastName = 'Jones';
fullName = firstName + lastName;
bothxp
16,510 PointsSo you have
var firstName = "will";
var lastName = "jones";
var fullName = (firstName ' ' + lastName);
document.write (fullName);
The problem is in the var fullname line. You want:
var fullName = firstName + ' ' + lastName;
You missed off the first + sign after firstName.
Anik Devaughn
7,751 PointsRandom Challenge:
var userInput = prompt("Enter any number"); var convertInputtoInt = parseInt(userInput);
var dicRoll = Math.floor(Math.random() * convertInputtoInt) + 1; alert("you generated this number " + dicRoll);
Stephen Sanchez
Courses Plus Student 843 PointsCode should like this:
var firstName = "will"; var lastName = "jones"; var fullName = ("firstName + lastName")
Michael Friedman
4,116 PointsI'm struggling to find my own errors: https://w.trhou.se/gw6tmbsu5d
Hasha K J
7,355 Pointsvar firstName = "Mary"; var lastName = "Jones"; var fullName = firstName + lastName; document.write(fullName);
garyfitzwater3
Courses Plus Student 1,666 PointsYeah I had a problem with that the fix is that the fourth line that has var fullName = ("firstName + lastName"). I would have though you would not have used "" as they are variable not strings. However, we are outputting strings from the variables I think thats the reason.
Sufiyaan Haroon
Full Stack JavaScript Techdegree Student 9,558 PointsThis is easy and can be answered different ways. You just have to combine the first variable with the last variable using +.
var firstName = "John";
var lastName = "Doe";
var lastName = firstName + lastName;