Connection between variables? i don't get it.. help?

can someone help me explain how are EVENT and previous code connected?
How does EVENT knows what will be the outcome of RANDOM?

const getRandEvent = () => {

const random = Math.floor(Math.random() * 3);

if (random === 0) {

return 'Marathon';

} else if (random === 1) {

return 'Triathlon';

} else if (random === 2) {

return 'Pentathlon';

}

};

const getTrainingDays = event => {

let days ;

if (event === ‘Marathon’) {

 days = 50;

} else if (event === ‘Triathlon’) {

 days = 100;

} else if (event === ‘Pentathlon’) {

 days = 200;

}

return days;

};

i can’t see any connection between that :frowning:

here:

const getTrainingDays = event => {

event is a parameter. Sort of like a placeholder, until it gets is value from argument at function call. So when we call the function we can provide an argument:

getTrainingDays('Marathon');

now 'Marathon' is passed to the parameter event

of course wrote a function to generate a random event, see if you can figure out how to use that :slight_smile:

@stetim94 makes it easier now yeah.
Thanks for the fast reply and your help :slight_smile: