I've come across this code and not sure why X works here.
function event() {
var eventS = 'triathlon';
eventOfTheDay(eventS);
}
function eventOfTheDay(x) {
return console.log('You set a reminder about ' + x);
}
event();
I've come across this code and not sure why X works here.
function event() {
var eventS = 'triathlon';
eventOfTheDay(eventS);
}
function eventOfTheDay(x) {
return console.log('You set a reminder about ' + x);
}
event();
The one and only thing about functions
in a programming language is that the parameter name can be any proper variable name according to its language's convention, and it is not mandatory to be the same variable name that you have used in your calling function.
A simple example:
You give some "thing" to your friend. You call it as "X" and your friend can call it as "Y". The thing is same. Its just the name that you and your friend are using according to your wish. The same is with functions
:)
In your example, you are passing 'triathlon'. You call it as eventS (Maybe you like to use it as eventS there because it makes sense there), and your friend (eventOfTheDay) calls it as x, or y or anything he wishes to (Because that new name can make sense there).