Come to an End explainer


#1

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()


#3

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


#4

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


#5

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