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 (Retired) Storing and Tracking Information with Variables The Variable Challenge

Gary Calhoun
Gary Calhoun
10,317 Points

Did I miss anything from this challenge?

First off I wanted to say I am really enjoying the way Dave teaches I am completely new to javascript and this is a fun way to learn. I wanted to make sure I didn't miss any steps so here is what I came up with for my program.

var userName = prompt("What is your name?");
var message = "Hello";
document.write("Hello " + userName + "! ");
var yourAge = prompt("How old are you?");
document.write(" Wow you are " + yourAge + " years old," + userName + " you are getting old");
alert(userName + " you have finished this program"); 

5 Answers

rydavim
rydavim
18,813 Points

You seem to have fulfilled all the challenge requirements, and your code runs error free for me. Good job!

(Apart from making me feel old when I ran your program. ;) )

It looks great! the only suggestion I would say is after the string years old in the document.write method is to have a space after the comma and before the quote. Other than that great job!

Gary Calhoun
Gary Calhoun
10,317 Points

Thanks Jacob will make that correction. I also noticed I could of added some html in there which I had overlooked to make it look a bit more presentable.

Sorry about that rydavim I made myself feel old myself when I tested it haha. Thanks for testing it for me!

I just updated the code actually.

var userName = prompt("What is your name?");
var message = "Hello";
document.write("<h1>Hello " + userName + "! </h1>");
var yourAge = prompt("How old are you?");
document.write(" <h1>Wow you are " + yourAge + " years old?, " + userName + " you are getting old!</h1>");
alert(userName + " you have finished this program.");

That's awesome! If you want to take this one step further, you can style the h1 tag by using CSS and add, styles to the program.

Gary Calhoun
Gary Calhoun
10,317 Points

Thanks, yeah that is a good idea maybe add css for h1 and h2 tags to give some separation and give them similar shaded colors based on importance.