Is this true?

I’m new to code and I don’t get it, why the value for alarm is 8:30 am? I mean sleepTimer has the value? So how or why does alarm work?

1 Like

The example shows two code elements.

First: a function definition. That takes one input parameter and processes this parameter by logging a string to the console. Via console.log("My alarm is set for: " + alarm);

Second: a function call. Only when you call a function it will actually do something.

Now you call the function sleepTimer with an input of '8:30AM'. The result is that the console gets a call to log ‘My alarm is set for: 8:30AM’.

Does this answer your question? Also I was wondering about why you picked undefined as an answer :wink:


to add to @janneslohmeijer excellent answer, the advantage of this approach is that we can set multiple alarms without having to write much extra code:


in case someone is struggling to get out of bed :stuck_out_tongue:


yeah okay I got it thanks :joy: :joy:

1 Like