0

In this function the cm variable has no data type eg var const or let. How does it still work without giving me an error?

          const inchToCm = inch => cm = inch * 2.54;

Is it because it used an implicit return?

lana james
  • 23
  • 3
  • 2
    it's just like if you had `function inchToCm(inch) { return cm = inch * 2.54; }` - does that help? i.e. `cm` will be a property on the global object (i.e. `window.cm` in a browser) – Jaromanda X Apr 17 '20 at 00:40
  • 2
    Also if you declare a variable without using a keyword, the variable will be global variable. See https://stackoverflow.com/questions/6888570/declaring-variables-without-var-keyword – Mickael B. Apr 17 '20 at 00:43

0 Answers0