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 Working with Strings and Finding Help

Phil Sta
Phil Sta
3,805 Points

Can someone have a quick look at my version of the shout code please?

Hi there,

I tried to come up with a solution for the shout code before looking at the solution and here it is:

var shout = prompt("What do you want to shout?"); console.log(shout); alert(shout.toUpperCase()+"!"); console.log(shout.toUpperCase()+"!");

It is different to the teacher's code but does work. Can someone give me a bit of feedback in terms of acceptable this is?

Thanks!

3 Answers

Gabriel Rumbaut
Gabriel Rumbaut
2,476 Points

Console.log isn't that important here, so you can remove it. Though early tutorials tend to focus on console.log as a means of determining values and whatnot, it's really just used on the developer side.

Your code does work, so good job! One tweak I'd say is important is to store the new values into variables, just so they can be accessed again. Remember, alert and console.log don't actually store anything. You need a variable to put it in--sort of like storing it in a box. Knowing when you need to store values in variables is going to be very important down the road.

You can either do var message = shout.toUpperCase() + "!"; or do Dragos's way of just changing the existing variable.

dragos busuioc
dragos busuioc
24,908 Points

or better ,instead creating a new variable , try this:shout= shout.toUpperCase() + "!"; and then print shout

dragos busuioc
dragos busuioc
24,908 Points

for me it looks great.but i think you should create before the alert a variable and asigned to that variable shout.toUpperCase()+"!";.and then put the variable created like argument for alert and last console.log