Linter - Parsing error: Unexpected token {

0

The teacher passed some exercises, one of them was to use Git and run a linter to check various code files. Here he gave me this code but I honestly could not understand or even identify it.

    // Você nao pode modificar as linhas de 2 à 5:
    const lib = {
    abc: 123,
    def: 234,
    };

    object =abc {
      def: lib.def,
      abc: lib.abc,
      xyz: 567,
    };

    console.log('O valor de abc est' + object.abc);
    
asked by anonymous 02.09.2017 / 23:18

2 answers

2

The error is syntax, more specifically in this part:

object =abc {
  def: lib.def,
  abc: lib.abc,
  xyz: 567,
};

The correct one would be:

object = {
  def: lib.def,
  abc: lib.abc,
  xyz: 567,
};

Because you are assigning an object to the variable object , and "abc" has no feeling where it was.

    
02.09.2017 / 23:42
0

The linter recommends using a new feature: ES2015 (ES6) named "Littéraux de gabarits" (in French) or "template literals". link

It is then possible to format a line of text by directly writing the name of the 'inline' variable.

To solve the problem, you must change

    console.log('O valor de abc est' + object);'

by

    console.log('O valor de abc est ${object}');
    
03.09.2017 / 00:51