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 trialPaul Lacey
4,899 PointsHey isn't this a correct answer?
NSString *color = @"Purple";
NSString *preference = @"My favorite color is ";
NSString *favorite = [color stringByAppendingString:preference];
Why won't it go through?
Update: Really just a question for the course makers. I think the test conditions are a bit off...
EDIT:I put objective-c so it highlights in the right way. Check out how i did it by looking at edit and see what i did. -Aurelian
2 Answers
Milo Winningham
Web Development Techdegree Student 3,317 PointsI think you've got the strings reversed. Appending preference
to color
would result in the string "PurpleMy favorite color is "
.
Patrick Cooney
12,216 PointsI believe this would give you "Purple My favorite color is ". Perfectly acceptable if you're Yoda. :-P if it helps, think of stringByAppendingString as a very long form of a + sign like you'd use in javascript or Java.
Patrick Cooney
12,216 PointsPatrick Cooney
12,216 PointsBeat me to it.
Paul Lacey
4,899 PointsPaul Lacey
4,899 Points<< user, error is. Thx!