JavaScript

Alejandro Rodriguez
Alejandro Rodriguez
3,020 Points

i never can use H1, H2.... what im doing wrong? document.write (<h2> 'Has vivido' + valor + 'en año' </h2>);

Wahts is wrong???

document.write (<h2>' y has vivido ' + horasvividas + ' horas'</h2>);

2 Answers

Emre Karakuz
Emre Karakuz
6,644 Points

Your code is missing apostrophe.

document.write('<h2>' + 'Has vivido' + valor + 'en año' + '</h2>');

or

document.write('<h2>Has vivido' + valor + 'en año</h2>');
Zoltan Parragi
Zoltan Parragi
2,868 Points

Try this:

var horasvividas = "something"; document.write ('<h2> y has vivido ' + horasvividas + ' horas </h2>');

Be careful with the quote marks. <h2> and </h2> must be within them.