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 trialmalcolm mowlam
3,856 Pointstask 2 java basics
still getting problems
firstName=("Malcolm");
lastName= ("Mowlam");
role = 'developer';
firstName=("Carlos");
lastName=("Salgado"); role=("developer");
msg = "firstname" ' + ' "lastname" ' + ' "role":"
console.log = msg
Tomasz Grodzki
8,130 PointsYou gettin this error because you have obvious mistakes.
Mistakes that make error:
- You didn't declared variables. You need to use a statement (like let or var) to declare variable
- You concatenate strings in wrong way. You have needless quotes. When you should quotes everything inside quotes is treated just like string, with any additional meaning. If you want to use operators like + you shouldn't use quote. Well... You can use quote but then + will be treated just like sign, not like an operator.
So in this case it should looks like:
const msg = firstName + ' ' + lastName + ': ' + role;
Mistakes that doesn't make errors in this challenge but are mistakes:
- You don't need to parenthesis to assign a value.
- Why are you tryin to assign values to variables twice?
- Why you wrote 'console.log = msg'?
2 Answers
Tomasz Grodzki
8,130 PointsFirstly, you don't have to start new topic to every new problem with the same task. You can make responses in the same topic.
Secondly, read carefully my post from your previous topic, please. Why u wrote + in quotes? I wrote you in previous response, that if you write any sign in quotes it's treated just like sign, without any additional meaning or reference.
And thirdly, it's not Java it's JavaScript.
Take care and happy coding!
malcolm mowlam
3,856 PointsGet cannot read property 1 of null
malcolm mowlam
3,856 Pointsmalcolm mowlam
3,856 PointsI'm getting fed up with keep getting property 1 is null and every time i go back i have to start from the beginning but thank you for your help it was really appreciated