2
I have the following code:
var modelo = 'Yamaha Fazer 250';
var fabricante = 'Yamaha';
var moto = {'Modelo - '+ modelo: fabricante};
I’m getting the following error code:
VM200:3 Uncaught Syntaxerror: Unexpected token +
2
I have the following code:
var modelo = 'Yamaha Fazer 250';
var fabricante = 'Yamaha';
var moto = {'Modelo - '+ modelo: fabricante};
I’m getting the following error code:
VM200:3 Uncaught Syntaxerror: Unexpected token +
2
The problem is on the following line:
var moto = {'Modelo - '+ modelo: fabricante};
put keys to resolve this incident:
var modelo = 'Yamaha Fazer 250';
var fabricante = 'Yamaha';
var moto = {['Modelo - '+ modelo]: fabricante};
Source: Computed properties
2
Hello, little headlight!
The warning
VM200:3 Uncaught SyntaxError: Unexpected token +
It says that there is an unexpected token, in which case it is the plus sign. You cannot concatenate the name of your attribute, just its value (the one on the right). To resolve, do the following
var modelo = 'Fazer 250';
var fabricante = 'Yamaha';
var moto = { modelo: fabricante + modelo };
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
I don’t think you can concatenate the attribute name there, you could do with the value:
{'Modelo': modelo + fabricante}
– Ricardo Pontual
but you can use the conchetes like this:
['Modelo - '+ modelo] : fabricante
– Ricardo Pontual