epicodus-curriculum / react-full-stack

3 stars 7 forks source link

Change variable name from "throw" to "toss" #41

Closed CalvinPVIII closed 10 months ago

CalvinPVIII commented 11 months ago

Description

Changes the example function from having a name of "throw" to having a name of "toss"

Motivation and Context

"throw" is a reserved word in JavaScript, so trying to create a function or a variable with the name "throw" will lead to some errors. Fixes this issue

How Has This Been Tested?

To verify that "throw" was not a valid name for a function or variable, I created a plain JavaScript file with following code:

const throw = () =>"hello"

throw()

And upon running the code with node, I received this error:

const throw = () =>"hello"
      ^^^^^

SyntaxError: Unexpected token 'throw'

In addition to the errors in my terminal, the VSCode JavaScript/TypeScript plugin also warned me with this error: 'throw' is not allowed as a variable declaration name.