JavaScript syntax error- Error on line 33: missing ; before statement... number after dot operator

152 Views Asked by At
// Create new object in the hash variable
var hash = new Object;

// Set wishard_modality variable to OBR.24.1
var wishard_modality = msg['OBR']['OBR.24']['OBR.24.1'].toString();

// Assign replacement values for the hash variable
hash.CAT = 'CT'; //Computed Tomography
hash.CT = 'CT'; //Computed Tomography
hash.RAD = 'CR'; //Computed Radiography
hash.CR = 'CR'; //Computed Radiography
hash.MRI = 'MR'; //Magnetic Resonance

I am trying to add

hash.999-other = 'OT';

but I get an error = Error on line 33: missing ; before statement

1

There are 1 best solutions below

0
CoderCharmander On

JavaScript variable (and function) name rules:

  • Can't start with a number
  • They can contain numbers however
  • They can start with _, $ or with an alphabetical character.
  • If they start with _, it must be followed by at least one number, alphabetical character, or $.
  • They can contain alphanumerical characters, _ and $.

So the name 999-other is not allowed.