+ 1

Hello please i want to know to put a space btw a string and a variable

e.g var a=love JavaScript I would like to see ( I + a) =I love JavaScript, and not (ilove JavaScript)

22nd May 2017, 11:28 PM
ibrahim danjuma
ibrahim danjuma - avatar
4 Answers
+ 8
var x = " love JavaScript."; document.write("I" + x); //Note the space before "love".
23rd May 2017, 4:45 AM
Biraj Patel
+ 7
As you can see, why not put a space in the string itself? If you are adding 2 string variables, why not do a ( StringA + " " + StringB ) inside there?
22nd May 2017, 11:43 PM
Wen Qin
Wen Qin - avatar
+ 3
var a = "love JavaScript"; document.write("I "+a);
22nd May 2017, 11:36 PM
CHMD
CHMD - avatar
+ 1
Make sure to put a space in string. Like this: var a= " love JavaScript". See there is a space before love. That will solve your problem. Here: var a = " love javascript" window.alert('I' + a) You can put that space in "I " like this. Doesn't really matter
22nd May 2017, 11:42 PM
Amiko Megrelishvili
Amiko Megrelishvili - avatar