Come to an End explainer

The aim of this puzzle: Add a new property to the object an then use it.

Walkthrough of the solution: The event object has 3 properties: title, location, and start. Each of these properties has a string value which you can use inside of print(). print(event.title) will output the value of the event's title property.

To add a new property called end, you tap on the placeholder __:__ on the last line of the object. The property name should go on the left side, so tap the left blank and type end. On the right side blank, you give a string value. Use the str button to create a new string, and type '2pm'. Now, the event object has an end property, and using event.end will give you the string '2pm'.

In the last print() statement, it should write the start and end times for the event. Tap on the event at the end of the print(), and then tap on the .end button to attach it to event.

Sample code solution:
(Tap below to reveal)

var event = {
  title: 'Haircut',
  location: 'Salon', 
  start: '1pm',
  end: '2pm'
};

print(event.title);
print('is from:');
print(event.start + ' to ' + event.end);

JavaScript Concepts: Binary Expression (+ concatenation), Code Block (object), Calling Functions, Data Structures (object), Identifiers, Member Expression, Variable Declaration

Grasshopper Concepts: print()

1 Like

There’s no .end on this puzzle. Also can’t edit the property to include end.

1 Like

You can add new properties to the object by tapping on the blank on the bottom row, __: __.

Tap the 1st blank to highlight it, the little keyboard icon should appear. Then tap it again to edit the property name. The full keyboard should open so you can type in 'end'.

Tap the 2nd blank and insert a new string using the str key.

–Frankie

2 Likes

Thanks, I finally worked it out. The puzzles up to then had the property name generated already.

The practice doesn’t work for this one.

1 Like

Hey there,

I can help if there are any problems with the puzzle, or if you’d like some extra lesson support. If you’d like to post a screenshot of your code, I’d be happy to take a look.

–Ben

2 Likes

Please help. I don’t understand why this isn’t working and it’s discourages me from learning more about coding.

Hey there, change End to end. That should solve the problem.

That fixed it. Thank you sooooooo much. I’ve been on that puzzle for like 3 weeks. I really appreciate that