0
var nome= "João";
var sobrenome="Silva";
var idade=30;
var resultado= nome +"" + sobrenome + 'terá' + idade +""+ 'anos';
console.log(resultado);
The exercise statement asks: declare a variable with a result name and assign a string joining its variables as follows: "João Silva will be 30 years old" and use the console.log to show what happens. Respect the spaces!
I created the code but it is giving error, what is wrong?
The code is right, only the spaces are missing. Instead of concatenating the strings with
""
, put the" "
(With a space between quotes). Spaces count as characters.– G. Bittencourt
Hi! A suggestion, you could do so to add spaces:
var resultado = [nome, sobrenome, 'terá', idade', 'anos'].join(' ');
– Sergio