+ 1
When adding a string in javascript how can i take space between them?
//please complete this var myAge = prompt(); var isAdult = (myAge > 18)? "Too young" : "Old enough"; alert ("You are" + isAdult); //the answer comes when I given the value of 42, gives (You areOld enough) //I need a space between the word 'are' and 'Old' <!--please help me-->
5 Réponses
+ 5
it is so simple,
write:
"you are "
give a space at the end.
another way, use `` (backticks) instead of quotes and you can insert variables within the string using
`you are ${isAdult}`
+ 1
or you can use:
"Hello" + " " + "World"
+ 1
Ok this time I need to get written in a new line,(by using document.write)
that means I have to start my JavaScript code is second line.
+ 1
'hello \n world'
+ 1
Or with backtickets:
`hello
world`