22.3k views
1 vote
Explain the naming rules for creating variables, and then provide three examples using the data types int, double, and char and assign values to them.

User Nhuluseda
by
4.6k points

1 Answer

1 vote

Answer:

I will answer for Javascript language.

Naming rules for creating variables:

The first character must begin with:

  • Letter of the alphabet.
  • Underscore ( _ ) (not recommended).
  • The dollar sign ($). (not recommended).

After the first character:

  • Letters.
  • Digits 0 to 9. No spaces or special characters are allowed.

About length:

  • No limit of length but is not recommended to use large names.

About case-sensitive:

  • Uppercase letters are distinct from lowercase.

About reserved words:

  • You can't use a Javascript reserved word for a name.

Example:

var ten = 10;

var pi = 3.14;

var name = 'Josh';

User Eton
by
5.7k points