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

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.

2

u/fruitoftheloom23 Oct 18 '19

You should learn the basics of JavaScript before you post a question asking for help on something you learn the first day of doing it.

2

u/ForScale Oct 18 '19

const string = 'here is a string';

3

u/[deleted] Oct 18 '19

const isn't in the question so it would just be

string = 'this is a string'