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
jl64
Full Stack JavaScript Techdegree Graduate 19,360 PointsMy character count keeps coming up as "undefined"
I think I followed the video correctly but I cannot get my code to display the number of characters, and I have tried changing it several times to closer mirror the code from the video. Here is what I am currently at.
var firstName = prompt("What is your first name?"); var lastName = prompt("What is your last name?"); var fullName = firstName.toUpperCase() + " " + lastName.toUpperCase(); var characterCount = fullName.legnth; alert("The string " + fullName + " is " + characterCount + " characters long.");
1 Answer
Connor Walker
17,985 PointsYou have a small typo here that is causing it to be undefined:
// This
var characterCount = fullName.legnth;
// Should be this
var characterCount = fullName.length;
Notice the g and n are the wrong way around, once you correct this it should work properly
jl64
Full Stack JavaScript Techdegree Graduate 19,360 Pointsjl64
Full Stack JavaScript Techdegree Graduate 19,360 PointsCompletely overlooked that! Thanks for your help!