Make a Name for Yourself explainer


The aim of this puzzle: Store a first, middle, and last name inside of an object and print it.
Walkthrough of the solution: When you run the code for the first time, you’ll see "Martin Luther Martin " printed out. Take a look at the print statement – name.first + name.middle + name.first. It should be printing a last name at the end, not the first name again. You can delete the .first, but there’s no .last key! That’s because your code doesn’t have an object with a last property, but there is an object called name which contains first and middle properties. You can add a new property to the object by tapping a new line above or below one of the other properties – you should see __⌨: __ Now you can add a last property by tapping the left side with the little keyboard icon. If quotation marks appear when you’re typing that means you’re creating a string – just tap the code to hide your keyboard, then delete the string. For this puzzle the .last button only gets created if the property name is an identifier. Once you create the last property inside of the object, you need to give it a string value. Now you have a .last button, so you can put name.last inside your print statement to print out the last name.
Sample code solution:
(Tap below to reveal)

var name = {
  first: 'Martin ',
  middle: 'Luther ',
  last: 'King '
print(name.first + name.middle + name.last);

JavaScript Concepts: Arithmetic Operators (+ string concatenation), Assignments, Binary Expression (+), Code Block (object)
Grasshopper Concepts: print()


I think I found a Bug, cause I didnt used last I used end as property and it shows the misstake message but everything was right
Then I changed booth end to last
then it worked


@Hochseefischer — can you share a screenshot of the code that caused the bug?


I completed the name puzzle as required but the app is not letting me proceed forward to the next stage? Can anyone help me?


Software don’t allow me to write “. last” property, instead completed with “. lsst” then don’t recognize this word either. So I’m stuck here.


Hey @bobsammer and @Nelson_Rodriguez,

Could you share a screenshot of the code you’re using? That way we can have a look and give you pointed on how to solve the puzzles.

H :slight_smile:


Why do you not need to include ’ ’ to generate spaces between the names? Thx.


The spaces are included at the end of the first and middle strings. We did this to simplify the final expression inside the print statement.



It’s a very worst text editor i have ever seen…first you need to improve your text editor…


It’s not a text editor; it’s a programming editor, with restrictions to ensure students only use specific features and prevent the creation of invalid code. Unfortunately, that makes it difficult to make certain types of corrections.


Hello, I understand everything in the code except the reasoning for the “.” after it says “name” . Does the period tell it to stop and find the first, middle, and last name? Beginner here but am loving this app. Thanks in advance for your help :blush:


Yes, pretty much. For example, in name.middle, the dot means middle can be found inside of the name object. If you use middle on its own, you’ll get an error, because there’s no middle variable created in your code; middle is a property of the name object, and it’s accessed by putting a dot between name and middle.



Okay, perfect. Thank you so much for your help on this. That makes perfect sense.


I don’t seem to be able to reproduce this puzzle in Playground. MartinLutherKing is what gets printed out. No spaces. Here’s the screenshot. What am I doing wrong?


I don’t know why the brackets are apearing


When adding several operators in a single command (like multiple + signs) we automatically add parentheses to show the order that things will be combined. In the case of print(...+...+...), the order doesn’t matter so you can ignore the parentheses.

In the original puzzle, there are spaces included in the first and middle names: 'Martin ' and 'Luther ' rather than 'Martin' and 'Luther'. This was simply to make the print statement have less terms and less + signs. The other option is to use: print(name.first + ' ' + name.middle + ' ' + name.last)



I had tried the second option before without success. Only Martin gets printed out.

The first option works though. Thanks!
However can u explain why the second option didn’t work for me?


Only name.first + ' ' is inside of your print statement parentheses. The name.middle + ' ' + name.last will create the 'Luther King' string, but since it’s outside of the print() it won’t be printed.

I should clarify what I meant by “the order doesn’t matter so you can ignore the parentheses.” The order that you’re combining the strings inside of print() doesn’t matter in the end, so you can ignore those. 'Martin ' + ('Luther ' + 'King') === ('Martin ' + 'Luther ') + 'King'

The opening and closing parentheses of the print() function do matter. print(a + b) is not the same as print(a) + b.

You want to move + name.middle + ' ' + name.last inside of the parentheses of print() if you want those to be printed.



Thanks for the explanation. I understand some things a little better now. Silly me didn’t explain my problem thoroughly. I did try to use the buttons to put in the correct code.
Print (name.first + ’ ’ + name.middle + ’ ’ + name.last);
What was printed out, as shown in the screenshot , was what the buttons gave me…with all the extra parentheses. I so wish sometimes that we had more access to the keyboard so that we could write the code ourselves. I know there must be a good reason for not having this option.


I didn’t understand… Could you please explain it in detail?