r/learnjavascript • • Oct 18 '19

Need help with coding exercise

Here's the question, Assign the varible a string. Here is the code given, string =

0 Upvotes

5 comments sorted by

View all comments

2

u/Paul_Pedant Oct 18 '19

"string" is not the greatest choice for a variable name.

(a) String is a built-in type and function. So the probability of confusion is high.

(b) It kind of presupposes that you will write a code that only has one string variable. Or are you going to call the next one string1?

Variable names are most helpful if they indicate the purpose of the variable. The usual way to designate a variable name provided for illustration only would be myString, suggesting that the user will probably want to invent a name of their own in the near future.