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?
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
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:
sleepTimer('8:35AM'); sleepTimer('8:40AM'); sleepTimer('8:45AM');
in case someone is struggling to get out of bed
yeah okay I got it thanks