How to include => with .on function?

https://jsfiddle.net/L19odehy/

I saw something on a tutorial page with => but on my side not want to work what I miss?

Thanks!

I do not see you are using => in your code anywhere. If you do not understand how to use =>, check out the ES6 section of the curriculum regarding arrow functions.

the arrow function works as follows:

(args) => {
//your code here
}

where args is your arguments it’s also called the arrow function or anonymous function, it works just as any other function but it’s anonymous, you’ll find it very useful to use with .map(), .filter()…etc

you can assign it a name as follows:

let myfunction = (args)=>{
//yourcodehere
}

you can read more here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

2 Likes